B
Bart Simpson
I have a class that has a member that is a const reference:
class MyClass
{
public:
MyClass(const AnotherClass& ac);
MyClass(const MyClass& mc);
MyClass& operator= (const MyClass& mc);
private:
const AnotherClass &m_ref ;
};
How do I implement the assignment "constructor"?
MyClass& MyClass:perator= (const MyClass& mc)
{
m_ref = mc.m_ref ; //dosen't compile (obviously)
m_ref(mc.m_ref) ; //dosen't compile (obviously)
}
class MyClass
{
public:
MyClass(const AnotherClass& ac);
MyClass(const MyClass& mc);
MyClass& operator= (const MyClass& mc);
private:
const AnotherClass &m_ref ;
};
How do I implement the assignment "constructor"?
MyClass& MyClass:perator= (const MyClass& mc)
{
m_ref = mc.m_ref ; //dosen't compile (obviously)
m_ref(mc.m_ref) ; //dosen't compile (obviously)
}