Click here to Skip to main content
15,890,399 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralTree view in vc++ Pin
accessnetwork5-Apr-05 0:41
accessnetwork5-Apr-05 0:41 
GeneralRe: Tree view in vc++ Pin
ThatsAlok5-Apr-05 0:53
ThatsAlok5-Apr-05 0:53 
GeneralImmediate Repainting of a ListCtrl Pin
Franz Klein5-Apr-05 0:16
Franz Klein5-Apr-05 0:16 
GeneralRe: Immediate Repainting of a ListCtrl Pin
Blake Miller6-Apr-05 6:31
Blake Miller6-Apr-05 6:31 
GeneralPlease help me! Pin
dSolariuM5-Apr-05 0:04
dSolariuM5-Apr-05 0:04 
GeneralRe: Please help me! Pin
David Crow5-Apr-05 3:05
David Crow5-Apr-05 3:05 
GeneralPlease help me! Pin
dSolariuM4-Apr-05 23:38
dSolariuM4-Apr-05 23:38 
GeneralRe: Please help me! Pin
ThatsAlok5-Apr-05 0:23
ThatsAlok5-Apr-05 0:23 
GeneralUsing a &lt;textarea&gt; in an Application Wizard Pin
Franz Klein4-Apr-05 23:37
Franz Klein4-Apr-05 23:37 
GeneralDebugging an Application Wizard Pin
Franz Klein4-Apr-05 23:17
Franz Klein4-Apr-05 23:17 
Generalstretchblt Pin
cher88230334-Apr-05 22:08
cher88230334-Apr-05 22:08 

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.