Copy constructor question (repost)

B

Bart Simpson

Didn't appear last time, trying again ...

I have a class that has a member that is a const reference:

class MyClass
{
public:
MyClass(const AnotherClass& ac);
MyClass(const MyClass& mc);
//....

private:
const AnotherClass &m_reference ;
};


How do I implement the copy constructor? (I get compilation erros with
this):

MyClass::MyClass(const MyClass& mc)
:m_reference(mc.m_reference)
{
//..
Copy();
}

Compiler error: Error error C3646: 'm_reference' : unknown override
specifier
 
V

Victor Bazarov

Bart said:
Didn't appear last time, trying again ...

I have a class that has a member that is a const reference:

class MyClass
{
public:
MyClass(const AnotherClass& ac);
MyClass(const MyClass& mc);
//....

private:
const AnotherClass &m_reference ;
};


How do I implement the copy constructor? (I get compilation erros with
this):

MyClass::MyClass(const MyClass& mc)
{
//..
Copy();
}

Compiler error: Error error C3646: 'm_reference' : unknown override
specifier

FAQ 5.8. Hint: need to see more to understand.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top