Can you tell me why output of that reference member of class different in different compilers?
class B
{
int& aRef;
public:
B(int c):aRef(c){}
void Print()
{
cout<<aRef<<endl;
}
};
void f(int s)
{
int& lcRef=s;
cout<<lcRef<<endl;
}
int main()
{
int x=100;
B s(x);
s.Print(); //ms c++ output : 3323244, gcc output :100
f(x); //ms c++ output : 100, gcc output:100
return 0;
}
And second question parameter of function f(int s)
behaves same logic as contructor of class B's initialization?