Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Timing milliseconds. Pin
Daniel Visan3-Jul-01 22:13
Daniel Visan3-Jul-01 22:13 
Generalhard disk full while writing to file Pin
Jake Palmer3-Jul-01 12:23
Jake Palmer3-Jul-01 12:23 
GeneralRe: hard disk full while writing to file Pin
Jonathon Lockett3-Jul-01 12:53
Jonathon Lockett3-Jul-01 12:53 
GeneralI thought I understood polymorphism Pin
Alex Griffing3-Jul-01 12:05
Alex Griffing3-Jul-01 12:05 
GeneralRe: I thought I understood polymorphism Pin
Alex Griffing3-Jul-01 12:16
Alex Griffing3-Jul-01 12:16 
GeneralRe: I thought I understood polymorphism Pin
Ben Burnett3-Jul-01 13:40
Ben Burnett3-Jul-01 13:40 
GeneralRe: I thought I understood polymorphism Pin
Alex Griffing3-Jul-01 13:57
Alex Griffing3-Jul-01 13:57 
GeneralRe: I thought I understood polymorphism Pin
Stan Shannon3-Jul-01 14:40
Stan Shannon3-Jul-01 14:40 
Well, first off, polymophism is NOT the answer to every programming problem you might confront. So maybe for whatever it is you are trying to achieve you SHOULD be using C functions. I have no idea why you are defining your contstructors as inline, or what effect it has on the virtual calls. I've never seen that done before, and have no clue why you would need it. However, consider that the virtual table does not exist prior to the construction of the object. How would you expect a virtual call from the constructor to work? Obviously, as stated, it is undefined.

You do not need to call an "Init" function after the ctor, because the object should initialize itself IN the ctor. Each derived class, will probably have unique initialization demands which do not warrent a virtual call anyway.

If I really needed a "virtual constructor" (re: Stroustrup)which is essentially what you are trying to achieve here I would do something like this:


class foo {
foo(); //default constructor.
foo( foo& rfoo ); // copy constructor.
virtual foo* Clone(){ return( new foo( *this )); }

virtual bar();

};

class fooplus : public foo {

fooplus();
fooplus( fooplus& rfooplus );

virtual fooplus* Clone(){ return( new fooplus( *this )); }

virtual bar();

};

In this way, an object can always return a properly initialized copy of itself on demand.





GeneralRe: I thought I understood polymorphism Pin
Alex Griffing3-Jul-01 16:33
Alex Griffing3-Jul-01 16:33 
GeneralRe: I thought I understood polymorphism Pin
Stan Shannon3-Jul-01 17:38
Stan Shannon3-Jul-01 17:38 
GeneralRe: I thought I understood polymorphism Pin
3-Jul-01 21:12
suss3-Jul-01 21:12 
GeneralRe: I thought I understood polymorphism Pin
Malcolm McMahon3-Jul-01 23:24
Malcolm McMahon3-Jul-01 23:24 
QuestionWho can give me a help???? Pin
3-Jul-01 11:26
suss3-Jul-01 11:26 
Questionmultiple active windows in MDI? Pin
Jake Palmer3-Jul-01 11:15
Jake Palmer3-Jul-01 11:15 
AnswerRe: multiple active windows in MDI? Pin
3-Jul-01 12:19
suss3-Jul-01 12:19 
GeneralRe: multiple active windows in MDI? Pin
Jake Palmer3-Jul-01 14:31
Jake Palmer3-Jul-01 14:31 
GeneralRe: multiple active windows in MDI? Pin
Ben Burnett3-Jul-01 18:45
Ben Burnett3-Jul-01 18:45 
AnswerRe: multiple active windows in MDI? Pin
#realJSOP4-Jul-01 1:06
professional#realJSOP4-Jul-01 1:06 
AnswerRe: multiple active windows in MDI? Pin
Jose Cruz4-Jul-01 11:35
Jose Cruz4-Jul-01 11:35 
GeneralGetCurrentDirectory Pin
3-Jul-01 10:45
suss3-Jul-01 10:45 
GeneralRe: GetCurrentDirectory Pin
Ghazi H. Wadi3-Jul-01 10:50
Ghazi H. Wadi3-Jul-01 10:50 
GeneralWord and WM_VSCROLL Pin
BobMatura3-Jul-01 10:08
BobMatura3-Jul-01 10:08 
Questionhow to include source code Pin
uma3-Jul-01 9:26
uma3-Jul-01 9:26 
AnswerRe: how to include source code Pin
Jonathon Lockett3-Jul-01 12:54
Jonathon Lockett3-Jul-01 12:54 
GeneralSoundBuffer problems. Pin
Daniel Selberg3-Jul-01 8:27
Daniel Selberg3-Jul-01 8:27 

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.