uninitialized references

Hello, I have a little problem with classes. Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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'

How can I fix this?
Thanks for help.
closed account (z05DSL3A)
Initialize a within a member initializer list:
1
2
3
4
CC(int &_a) 
:a(_a)
{ 
}
Thanks!
Topic archived. No new replies allowed.