473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Copy constructor question (repost)

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

May 23 '07 #1
3 1376
Bart Simpson wrote:
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
FAQ 5.8. Hint: need to see more to understand.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 23 '07 #2


Victor Bazarov wrote:
Bart Simpson wrote:
>>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


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

V
Fixed: I was missing the ":" at start of the initialization list
May 23 '07 #3

Victor Bazarov wrote in message ...
Bart Simpson wrote:
MyClass::MyClass(const MyClass& mc)
// -- missing a colon here, for one thing. --
m_reference(mc.m_reference)
{
//..
Copy();
}

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

FAQ 5.8. Hint: need to see more to understand.
--
Bob R
POVrookie
May 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
4
by: Kench | last post by:
Sorry if this becomes a repost. I posted this to comp.lang.c++.moderated 1 hour ago still it does not show up there so posting this here. Hi, Consider class A & B both of which implement a copy...
8
by: Jesper | last post by:
Hi, Does the concept "copy constructor" from c++ excist in c#. What is the syntax. best regards Jesper.
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
8
by: shuisheng | last post by:
Dear All, I am wondering how the default copy constructor of a derived class looks like. Does it look like class B : public A { B(const B& right) : A(right) {}
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.