class CC
{
public:
int &a;
CC(int &_a)
{
a=_a;
}
void print()
{
cout <<a<<" ";
}
};
int main()
{
int i=10;
CC cc(i);
cc.print(); // print 10
i=11; // i has changed so cc.a must change its value too
cc.print(); // should print 11
getchar();
}
So basically I want to make CC::a always equal to i but I'm getting error:
D:\C++\sudas\test.cpp uninitialized reference member `CC::a'