adress value
parameter in negative function is an adress But i can send as int
and the program gives correct result why?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
void negative(int &i) ;
int main()
{
int k = 10 ;
cout << "positive : " << k << endl;
int &j = k ;
cout << "j : " << &j << endl;
negative(j);
cout << "negative : " << k << endl;
return 0 ;
}
void negative(int &i)
{
i = - i ;
}
|
OK Compiler does this automatically.
parameter in negative function is an adress |
void negative(int &i)
No, it isn't. It's a reference.
Last edited on
Topic archived. No new replies allowed.