Hey...I need help.
I was atempting to pass a reference through a class method and then use the method to access the private integer 'age' with the reference. This isn't for a program but I need to understand this. Any help would be apreciated.
My compiler is :MSVC++ 6...the error is located at the bottom. What I need to know is how to access the private int age using a reference...thanks.
class dog //Telling compiler what a dog is..
void setAge(int &rAge) //passing a reference
rAge=age; //declaring the reference to age.
dog SkinBag; //Making my dog...
SkinBag.setAge(5); //error line ... Setting skinbags age
D:\Vc98\playingaround.cpp(19) : error C2664: 'setAge' : cannot convert parameter 1 from 'const int' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue