Skip to main content

All Questions

0 votes
2 answers
56 views

Batch function get the value of variable pass by reference

In the below script, there is passed var1 by reference to myDosFunc, so it can change the value. How can the value of the referenced variable be get within the function without having to pass the ...
David Maisonave's user avatar
1 vote
1 answer
57 views

Error in using call by reference with function to change the head of a singly linked list

I'm learning linked lists in C, and have come across an error when trying to add a value at beginning of a linked list using functions #include<stdio.h> #include<stdlib.h> struct node{ ...
Cap_Void's user avatar
5 votes
1 answer
103 views

Difference on passing a free function as template argument by value or by reference

Consider this code (godbolt): #include <iostream> template<typename F> void call_by_val(F funct) { std::cout << "call_by_val(): "; funct(); } template<...
MatG's user avatar
  • 796
2 votes
1 answer
112 views

How to attach a class function as an ISR callback

I am trying to attach a class function as an ISR callback but I am getting this error: lib/classA/classA.cpp: In member function 'uint8_t MethodA::Init()': lib/classA/classA.cpp:32:71: error: invalid ...
Michael Hanagan's user avatar
-3 votes
1 answer
79 views

Can someone explain to me why after this function is called a becomes 2 instead of 3 or 4?

#include <iostream> using namespace std; void f(int &x, int &y) { x = 1; x = x + y; } int main() { int a = 3; f(a, a); cout<<a; return 0; } I found this ...
Weegee's user avatar
  • 5
0 votes
1 answer
56 views

Why my print statement inside the swap function is giving such output?

#include <stdio.h> void swap(int* x, int* y){ int temp; temp = *x; *x = *y; *y = temp; printf("The value of x and y inside the function is x = %d and y = %d", x, y);...
Manash JB's user avatar
0 votes
0 answers
54 views

compiler does not complain when I do std::move of a const reference [duplicate]

I'm trying to understand which is the most optimized way to pass arguments to functions. I got the answer for the book professional c++ but during some test I ran into a weird behavior. It's clear ...
DarioZ's user avatar
  • 29
0 votes
0 answers
63 views

What is the best way to pass an object by reference in JavaScript without modifying it

I studied that Javascript passes objects by 'pass by reference' to functions. When those objects are mutated/updated inside a function, then it affects the original object. This is clear! let obj = { ...
Programmer's user avatar
0 votes
1 answer
53 views

'=' left operator must be an l-value problem encountered while passing value from a function in visual studio C

I'm programming in visual studio C. The program consist tomonitorate monopoly's game and I was wondering about how to passing value of a matrix of struct from a function, but it gaves me error C2106 ('...
ToTosty's user avatar
  • 36
0 votes
1 answer
98 views

Why does the variable, passed as an address to a function, not change its value even if the value is changed in the function?

So, I passed the address of a variable to a particular function. And I changed the value of the variable using pointers inside the function, the change is reflected when I print the variable in the ...
sam907's user avatar
  • 3
0 votes
2 answers
83 views

How do I call multiple python functions by reference to operate on a variable so that I can change the sequence of function calls easily?

I want to create a 'function pipeline', like a factory. Let's say I have the following functions: def func1(var): var = # do something with var return var def func2(var): var = # do ...
skeetastax's user avatar
  • 1,774
-1 votes
2 answers
582 views

Why did this python list appear to get passed "by value"? [duplicate]

I defined the following function: def myFunction(a): print(f'In function, initial a = {a}, {id(a)}, {type(a)}') a = a*10 print(f'In function, final a = {a}, {id(a)}, {type(a)}') return a When ...
Kanika's user avatar
  • 1
0 votes
2 answers
71 views

"While loop" (contains pointer to array passed into a function) works only once

I am writing some code in C. Inside the main function there is a while loop with a function call to printboard taking a pointer to array board. Inside the function I have got a printf, that prints 3 ...
Filip Dvorak's user avatar
0 votes
2 answers
246 views

Does a function output parameter (a reference paramter) change before the function returns? [closed]

Basically I want to know in C++ if I call a function and pass the arguments by reference, then the arguments are modified only after the function returns or it is possible that they get changed ...
Puya's user avatar
  • 61
2 votes
1 answer
167 views

Confusion about making binary search tree EMPTY in C

I want to define a function which makes binary search tree to empty with return-type void. These are my codes as below : _Node structure typedef struct _Node { int data; struct _Node* l_child; ...
bFur4list's user avatar
  • 133

15 30 50 per page
1
2 3 4 5
19