Click here to Skip to main content
15,891,423 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Which Mouse? Pin
Anthony Mushrow7-Dec-07 14:56
professionalAnthony Mushrow7-Dec-07 14:56 
GeneralRe: Which Mouse? Pin
Mike Dimmick7-Dec-07 16:11
Mike Dimmick7-Dec-07 16:11 
GeneralRe: Which Mouse? Pin
Storm-blade8-Dec-07 10:45
professionalStorm-blade8-Dec-07 10:45 
QuestionRe: Which Mouse? Pin
RobertE9-Dec-07 8:17
RobertE9-Dec-07 8:17 
GeneralKnowing when user deletes a file with CFileDialog Pin
Henri7-Dec-07 7:55
Henri7-Dec-07 7:55 
GeneralRe: Knowing when user deletes a file with CFileDialog Pin
Maximilien7-Dec-07 9:11
Maximilien7-Dec-07 9:11 
GeneralRe: Knowing when user deletes a file with CFileDialog Pin
Mark Salsbery7-Dec-07 9:18
Mark Salsbery7-Dec-07 9:18 
GeneralClass Constructor Problem Pin
Lea Hayes7-Dec-07 6:47
Lea Hayes7-Dec-07 6:47 
Hi all,

I have a class, for the purposes of this message 'class AClass'. The class requires a copy-constructor for the typical purposes. The following represents what I usually do:

class AClass<br />
{<br />
public:<br />
   AClass();<br />
   AClass(const AClass& copy_from);<br />
<br />
   ...<br />
};


In my implementation 'AClass' initiates a large amount of data whilst potentially undertaking a fairly complex procedure. The entire procedure can be optimised very easily when a non-constant version of the object is supplied:

class AClass<br />
{<br />
public:<br />
   AClass();<br />
   AClass(AClass& copy_from);<br />
<br />
   ...<br />
};


However, this leads to a different problem because the 'const' keyword is no longer used. There are places within my application which must parse such objects as 'const'. So the natural solution would seem the following:

class AClass<br />
{<br />
public:<br />
   AClass();<br />
   AClass(AClass& copy_from);<br />
   AClass(const AClass& copy_from);<br />
<br />
   ...<br />
};


Sadly the above produces the following warning message:
'warning C4521: 'AClass' : multiple copy constructors specified'

I know there are workarounds which involve 'const_cast', but in my application the two copy constructors need to behave differently. Also, it isn't appropriate to use pointers and references to avoid this issue because it would cause serious maintenance issues and would be too confusing.

Any help or advice would be great.
Lea Hayes
GeneralRe: Class Constructor Problem Pin
Lea Hayes7-Dec-07 7:13
Lea Hayes7-Dec-07 7:13 
GeneralRe: Class Constructor Problem Pin
Cedric Moonen7-Dec-07 7:15
Cedric Moonen7-Dec-07 7:15 
AnswerRe: Class Constructor Problem Pin
Nathan Holt at EMOM7-Dec-07 7:16
Nathan Holt at EMOM7-Dec-07 7:16 
GeneralRe: Class Constructor Problem Pin
Lea Hayes7-Dec-07 7:55
Lea Hayes7-Dec-07 7:55 
QuestionRe: Class Constructor Problem Pin
Maximilien7-Dec-07 7:18
Maximilien7-Dec-07 7:18 
GeneralRe: Class Constructor Problem Pin
Lea Hayes7-Dec-07 7:50
Lea Hayes7-Dec-07 7:50 
GeneralRe: Class Constructor Problem Pin
led mike7-Dec-07 8:28
led mike7-Dec-07 8:28 
GeneralRe: Class Constructor Problem Pin
cp98767-Dec-07 9:45
cp98767-Dec-07 9:45 
Generalkeyboard buffer Pin
RomTibi7-Dec-07 6:40
RomTibi7-Dec-07 6:40 
AnswerRe: keyboard buffer Pin
Nathan Holt at EMOM7-Dec-07 7:23
Nathan Holt at EMOM7-Dec-07 7:23 
GeneralRe: keyboard buffer Pin
RomTibi9-Dec-07 4:29
RomTibi9-Dec-07 4:29 
General(Dundas Grid related) Modal dialog called from an event in the grid is not modal at all. [modified](SOLVED) Pin
Maximilien7-Dec-07 5:45
Maximilien7-Dec-07 5:45 
GeneralRe: (Dundas Grid related) Modal dialog called from an event in the grid is not modal at all. Pin
James R. Twine7-Dec-07 6:14
James R. Twine7-Dec-07 6:14 
GeneralCObject (CView - CDoument) callbacks Pin
Tony Teveris7-Dec-07 4:48
Tony Teveris7-Dec-07 4:48 
GeneralRe: CObject (CView - CDoument) callbacks Pin
led mike7-Dec-07 6:04
led mike7-Dec-07 6:04 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Mark Salsbery7-Dec-07 6:24
Mark Salsbery7-Dec-07 6:24 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Tony Teveris7-Dec-07 6:51
Tony Teveris7-Dec-07 6:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.