0
Passing Global Variables in C++
Can we pass the address of global variables in C++(pass by reference) .Will it affect the actual value of the variable?
4 Respostas
+ 9
There is no need to pass a global variable. You can directly alter the value of a global variable in any existing function.
+ 9
#include <iostream>
int y = 10;
void test(int& num)
{
num = 11;
}
int main()
{
test(y);
std::cout << y;
return 0;
}
// outputs 11
+ 1
but if we do will the value be altered
0
thanks bro