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

C / C++ / MFC

 
GeneralVirtual base class constructor Pin
George_George23-Mar-08 3:33
George_George23-Mar-08 3:33 
GeneralRe: Virtual base class constructor Pin
CPallini23-Mar-08 4:31
mveCPallini23-Mar-08 4:31 
GeneralRe: Virtual base class constructor Pin
George_George23-Mar-08 4:37
George_George23-Mar-08 4:37 
GeneralRe: Virtual base class constructor Pin
CPallini23-Mar-08 5:25
mveCPallini23-Mar-08 5:25 
GeneralRe: Virtual base class constructor Pin
George_George23-Mar-08 19:34
George_George23-Mar-08 19:34 
GeneralRe: Virtual base class constructor Pin
CPallini23-Mar-08 22:25
mveCPallini23-Mar-08 22:25 
GeneralRe: Virtual base class constructor Pin
George_George23-Mar-08 22:53
George_George23-Mar-08 22:53 
GeneralRe: Virtual base class constructor Pin
CPallini23-Mar-08 23:45
mveCPallini23-Mar-08 23:45 
Somethimes an example is better than a thousand of words:

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

class AB: 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: 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;
}



If you put a breakpoint at the end of main function and put abcd inside the watch window, then you'll see something like the following
-		abac	{abac=4 }	ABAC
-		AB	{ab=1 }	AB
-		A	{a=0 }	A
-		__vfptr	0x0041574c const ABAC::`vftable'{for `AB'}	*
		[0]	0x00411136 ABAC::do_things(int)	*
		a	0	int
		ab	1	int
-		AC	{ac=2 }	AC
-		A	{a=0 }	A
-		__vfptr	0x00415740 const ABAC::`vftable'{for `AC'}	*
		[0]	0x0041111d [thunk]:ABAC::do_things`adjustor{12}' (int)	*
		a	0	int
		ac	2	int
		abac	4	int


Line [0] 0x0041111d [thunk]:ABAC::do_things`adjustor{12}' (int) * shows the adjustor, i.e. the offset (equalt to 12 decimal, 0xC hex) needed to align vftable'{for `AC'} to ::`vftable'{for `AB'} (0x00415740 + 0x0000000c = 0x0041574c).

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke


GeneralRe: Virtual base class constructor Pin
George_George24-Mar-08 0:11
George_George24-Mar-08 0:11 
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 
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 

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.