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

C / C++ / MFC

 
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 
I don't know what you are trying to achieve, but even if you were to manage to have two different copy constructors now, I think you would be laying a maintenance minefield. Reading your code it is not easy to understand which version will be invoked and what happens. Seeing

AClass a(b)
gives no clue that b is modified. You, or others, may not recall this when maintaining the code.


If possible, implement the const copy constructor that uses a const object.

Think of a good descriptive name to call the non-const version, and do a two-step construction, if necessary creating a separate constructor to create an empty or invalid object, e.g.

AClass a;<br />
a.CopyFromAndModify(b);


If these are always created on the heap you could make a simple helper function to do the work

AClass* pA = CreateNewClassAndModify(b);

I'm sure there are other ways.




Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

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 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Mark Salsbery7-Dec-07 7:11
Mark Salsbery7-Dec-07 7:11 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Tony Teveris7-Dec-07 7:18
Tony Teveris7-Dec-07 7:18 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Mark Salsbery7-Dec-07 7:34
Mark Salsbery7-Dec-07 7:34 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Tony Teveris7-Dec-07 8:03
Tony Teveris7-Dec-07 8:03 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Mark Salsbery7-Dec-07 8:18
Mark Salsbery7-Dec-07 8:18 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Tony Teveris7-Dec-07 8:23
Tony Teveris7-Dec-07 8:23 
GeneralRe: CObject (CView - CDoument) callbacks Pin
Mark Salsbery7-Dec-07 8:29
Mark Salsbery7-Dec-07 8:29 
GeneralExecutable application Pin
llp00na7-Dec-07 4:28
llp00na7-Dec-07 4:28 

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.