Click here to Skip to main content
15,913,487 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ATTRIBUTE Pin
sunit55-Apr-05 3:11
sunit55-Apr-05 3:11 
GeneralWELL DONE Pin
BadJerry5-Apr-05 3:35
BadJerry5-Apr-05 3:35 
GeneralRe: WELL DONE Pin
ThatsAlok5-Apr-05 3:53
ThatsAlok5-Apr-05 3:53 
GeneralRe: WELL DONE Pin
BadJerry5-Apr-05 4:06
BadJerry5-Apr-05 4:06 
GeneralRe: WELL DONE Pin
ThatsAlok5-Apr-05 17:54
ThatsAlok5-Apr-05 17:54 
GeneralMFC Pin
charu1235-Apr-05 2:11
charu1235-Apr-05 2:11 
GeneralRe: MFC Pin
toxcct5-Apr-05 2:22
toxcct5-Apr-05 2:22 
GeneralRe: MFC Pin
charu1235-Apr-05 19:31
charu1235-Apr-05 19:31 
GeneralCant use Ctrl+C etc. with CSplitterWnd Pin
ugur_basak5-Apr-05 1:40
ugur_basak5-Apr-05 1:40 
GeneralFlat CComboBoxEx Pin
BadJerry5-Apr-05 1:31
BadJerry5-Apr-05 1:31 
GeneralRe: Flat CComboBoxEx Pin
Alexander M.,5-Apr-05 8:36
Alexander M.,5-Apr-05 8:36 
Questionhow to setfocus.. Pin
mpallavi5-Apr-05 1:28
mpallavi5-Apr-05 1:28 
AnswerRe: how to setfocus.. Pin
toxcct5-Apr-05 1:49
toxcct5-Apr-05 1:49 
Generalthanx Pin
mpallavi5-Apr-05 1:57
mpallavi5-Apr-05 1:57 
GeneralWindows Tree view in vc++ Pin
accessnetwork5-Apr-05 1:21
accessnetwork5-Apr-05 1:21 
QuestionSelf-initilization of class? Pin
Gadjuka5-Apr-05 1:09
Gadjuka5-Apr-05 1:09 
AnswerRe: Self-initilization of class? Pin
S. Senthil Kumar5-Apr-05 1:29
S. Senthil Kumar5-Apr-05 1:29 
GeneralRe: Self-initilization of class? Pin
Cedric Moonen5-Apr-05 2:38
Cedric Moonen5-Apr-05 2:38 
GeneralRe: Self-initilization of class? Pin
Ravi Bhavnani5-Apr-05 2:55
professionalRavi Bhavnani5-Apr-05 2:55 
S. Senthil Kumar wrote:
virtual functions don't work from within the constructor.


Unfortunately, this statement can be misconstrued. You can call a virtual function in a constructor as long as the implementation of that function exists.

So, while the following scenario is invalid (and results in a linker error since Base::foo() isn't defined)
class Base {
public:
  Base() { foo(); }       // Default constructor <code><------ (invalid)</code>
  virtual ~Base() { }     // Standard destructor
  virtual void foo() = 0; // Pure virtual function
};
 
class Derived : public Base {
public:
  Derived() : Base() { }; // Default constructor
  virtual ~Derived() { }  // Standard destructor
  virtual void foo()      // Virtual func implementation
    { printf ("Derived::foo()\n"); }
};
this scenario is valid:
class Base {
public:
  Base() { }              // Default constructor
  virtual ~Base() { }     // Standard destructor
  virtual void foo() = 0; // Pure virtual function
};
 
class Derived : public Base {
public:
  Derived() : Base() { foo(); }; // Default constructor <code><------ (valid)</code>
  virtual ~Derived() { }         // Standard destructor
  virtual void foo()             // Virtual func implementation
    { printf ("Derived::foo()\n"); }
};
/ravi

My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com

GeneralRe: Self-initilization of class? Pin
S. Senthil Kumar5-Apr-05 4:23
S. Senthil Kumar5-Apr-05 4:23 
GeneralRe: Self-initilization of class? Pin
Ravi Bhavnani5-Apr-05 5:46
professionalRavi Bhavnani5-Apr-05 5:46 
AnswerRe: Self-initilization of class? Pin
Cedric Moonen5-Apr-05 2:29
Cedric Moonen5-Apr-05 2:29 
AnswerRe: Self-initilization of class? Pin
Gadjuka5-Apr-05 5:42
Gadjuka5-Apr-05 5:42 
GeneralRe: Self-initilization of class? Pin
S. Senthil Kumar5-Apr-05 20:49
S. Senthil Kumar5-Apr-05 20:49 
GeneralUrgent Help Pin
5-Apr-05 0:43
suss5-Apr-05 0:43 

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.