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

C / C++ / MFC

 
GeneralRe: Virtual base class constructor Pin
CPallini24-Mar-08 0:29
mveCPallini24-Mar-08 0:29 
GeneralRe: Virtual base class constructor Pin
George_George24-Mar-08 3:01
George_George24-Mar-08 3:01 
GeneralRe: Virtual base class constructor Pin
CPallini24-Mar-08 6:11
mveCPallini24-Mar-08 6:11 
GeneralRe: Virtual base class constructor Pin
George_George24-Mar-08 21:26
George_George24-Mar-08 21:26 
GeneralRe: Virtual base class constructor Pin
CPallini24-Mar-08 23:36
mveCPallini24-Mar-08 23:36 
GeneralRe: Virtual base class constructor Pin
George_George25-Mar-08 3:00
George_George25-Mar-08 3:00 
GeneralRe: Virtual base class constructor Pin
CPallini25-Mar-08 5:08
mveCPallini25-Mar-08 5:08 
GeneralRe: Virtual base class constructor Pin
George_George25-Mar-08 20:36
George_George25-Mar-08 20:36 
Thanks CPallini,


I read again my original question and your sample. I think we are making a big mistake. Smile | :)

The question about virtual base class and virtual inheritance. But in your sample below, none is about virtual inheritance. I modified the code below to make virtual inheritance.

My question is about,

--------------------
From MSDN virtual base class reference, what means "If a derived class overrides a virtual function that it inherits from a virtual base class, and if a constructor or a destructor for the derived base class calls that function using a pointer to the virtual base class, the compiler may introduce additional hidden "vtordisp" fields into the classes with virtual bases."

I do not understand why an additional hidden filed is needed?
--------------------

1.

Do you think my modification of your sample reflects the issue described above?

2.

I noticed you invoke virtual function do_things of class A, in class AB's constructor. I am confused whether it is the same scenario as mentioned in MSDN document, "a constructor or a destructor for the derived base class". Does MSDN mean calling virtual function from constructor of base class A or derived class AB? The term "the derived base class" makes me confused. Smile | :)

It is appreciated if you could clarify.

#include <iostream>

using namespace std;

class A
{
	int a;public:	A(){a=0;}	
	virtual int do_things(int a){this->a = a; return 0;}
};

class AB: virtual public A
{	
	int ab;
public:
	AB(){ab=1;}
	virtual int do_things(int a){A::do_things(a);this->ab = a+1; return 1;}
};

class AC: virtual public A
{
	int ac;
public:	
	AC(){ac=2;}
	virtual int do_things(int a){A::do_things(a);this->ac = a+2; return 2;}
};

class ABAC: public AB, public AC
{
	int abac;
public:
	ABAC(){abac = 4;}
	virtual int do_things(int a){AB::do_things(a);AC::do_things(a);this->abac = a+4; return 4;}
};

int main()
{
	ABAC abac;

	return 0;
}



regards,
George
GeneralRe: Virtual base class constructor Pin
CPallini25-Mar-08 22:45
mveCPallini25-Mar-08 22:45 
GeneralRe: Virtual base class constructor Pin
George_George25-Mar-08 23:30
George_George25-Mar-08 23:30 
Generalcode for active x controls in vc++ Pin
kumartnvr23-Mar-08 2:54
kumartnvr23-Mar-08 2:54 
GeneralRe: code for active x controls in vc++ Pin
CPallini23-Mar-08 4:20
mveCPallini23-Mar-08 4:20 
Generalextended style problem, compiles but not take effect Pin
followait22-Mar-08 22:49
followait22-Mar-08 22:49 
QuestionRe: extended style problem, compiles but not take effect Pin
CPallini23-Mar-08 0:30
mveCPallini23-Mar-08 0:30 
GeneralRe: extended style problem, compiles but not take effect Pin
followait23-Mar-08 0:57
followait23-Mar-08 0:57 
Questioni want to make usb control system~give me tip please~ Pin
Jung Seng Won22-Mar-08 19:27
Jung Seng Won22-Mar-08 19:27 
GeneralRe: i want to make usb control system~give me tip please~ Pin
CPallini23-Mar-08 0:36
mveCPallini23-Mar-08 0:36 
QuestionUnhandle exception in DAO350.dll Pin
clever10122-Mar-08 17:27
clever10122-Mar-08 17:27 
GeneralRe: Unhandle exception in DAO350.dll Pin
Mark Salsbery23-Mar-08 7:17
Mark Salsbery23-Mar-08 7:17 
QuestionHow to submit (ie control) Pin
chinakknd22-Mar-08 16:05
chinakknd22-Mar-08 16:05 
AnswerRe: How to submit (ie control) Pin
Rajkumar R22-Mar-08 23:56
Rajkumar R22-Mar-08 23:56 
GeneralRe: How to submit (ie control) Pin
chinakknd23-Mar-08 15:38
chinakknd23-Mar-08 15:38 
GeneralRe: How to submit (ie control) Pin
Rajkumar R23-Mar-08 18:17
Rajkumar R23-Mar-08 18:17 
GeneralRe: How to submit (ie control) Pin
chinakknd24-Mar-08 16:14
chinakknd24-Mar-08 16:14 
GeneralSetting the cursor for MFC MDI child windows Pin
Californian222-Mar-08 12:34
Californian222-Mar-08 12:34 

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.