Hi , I have a const member function which returns a protected member of a class.Like this Code: class A { protected: int Number; public: int Get_Number (void) const { return(Number); } }; I want to use the value returned by the Get_Number function. How can i do int temp=Data.Get_Number(); is giving me an execption(Data is of type "A&") Can anyone help me??...
Code: class MyTest { protected: int n; public: int GetVal()const { return n; } void SetVal(int num) { n=num; } }; int main() { int temp; MyTest obj; obj.SetVal(10); temp=obj.GetVal(); cout<<temp; return 0; } This code has no problems. What's your problem??? Let me know exactly what u wanna?