Pass a reference to a reference
I think it's illegal to pass a reference to a reference in C++.However
,when I run this code it gives me no error.
void g(int& y)
{
std::cout << y;
y++;
}
void f(int& x)
{
g(x);
}
int main()
{
int a = 34;
f(a);
return 0;
}
Doesn't the formal parameter of g() qualify as a reference to a reference ??
No comments:
Post a Comment