Click here to Skip to main content
15,889,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFaster than memcpy()... Pin
bulg20-Nov-08 11:50
bulg20-Nov-08 11:50 
AnswerRe: Faster than memcpy()... Pin
BobInNJ20-Nov-08 12:51
BobInNJ20-Nov-08 12:51 
GeneralRe: Faster than memcpy()... Pin
PJ Arends20-Nov-08 14:41
professionalPJ Arends20-Nov-08 14:41 
GeneralRe: Faster than memcpy()... Pin
Randor 20-Nov-08 22:30
professional Randor 20-Nov-08 22:30 
GeneralRe: Faster than memcpy()... Pin
BobInNJ21-Nov-08 6:06
BobInNJ21-Nov-08 6:06 
GeneralRe: Faster than memcpy()... Pin
Randor 21-Nov-08 6:21
professional Randor 21-Nov-08 6:21 
AnswerRe: Faster than memcpy()... Pin
cmk20-Nov-08 16:51
cmk20-Nov-08 16:51 
QuestionA Question about Constructors Pin
BobInNJ20-Nov-08 8:17
BobInNJ20-Nov-08 8:17 
Please consider the following C++ program:

#include <iostream><br />
<br />
using namespace std;<br />
<br />
class Base0 {<br />
public:<br />
	Base0()<br />
	{<br />
		cout << "Base0::Base0() called" << endl;<br />
	}<br />
	~Base0()<br />
	{<br />
		cout << "Base0::~Base0() called" << endl;<br />
	}<br />
<br />
};<br />
<br />
class Base1 {<br />
public:<br />
	Base1()<br />
	{<br />
		cout << "Base1::Base1() called" << endl;<br />
	}<br />
	~Base1()<br />
	{<br />
		cout << "Base1::~Base1() called" << endl;<br />
	}<br />
<br />
};<br />
<br />
class Base2 {<br />
public:<br />
	Base2()<br />
	{<br />
		cout << "Base2::Base2() called" << endl;<br />
	}<br />
	~Base2()<br />
	{<br />
		cout << "Base2::~Base2() called" << endl;<br />
	}<br />
<br />
};<br />
<br />
class Base3 {<br />
public:<br />
	Base3()<br />
	{<br />
		cout << "Base3::Base3() called" << endl;<br />
	}<br />
	~Base3()<br />
	{<br />
		cout << "Base3::~Base3() called" << endl;<br />
	}<br />
<br />
};<br />
<br />
class Test1 : public Base0, virtual Base1 {<br />
public:<br />
	Test1()<br />
	{ cout << "Test1::Test1() called" << endl; }<br />
	~Test1()<br />
	{ cout << "Test1::~Test1() called" << endl; }<br />
};<br />
<br />
class Test2 : public virtual Base1, Base2, Base3 {<br />
public:<br />
	Test2()<br />
	{ cout << "Test2::Test2() called" << endl; }<br />
	~Test2()<br />
	{ cout << "Test2::~Test2() called" << endl; }<br />
};<br />
<br />
<br />
class Test3 : public Test1, virtual Test2 {<br />
public:<br />
	Test3()<br />
	{ cout << "Test3::Test3() called" << endl; }<br />
	~Test3()<br />
	{ cout << "Test3::~Test3() called" << endl; }<br />
};<br />
<br />
<br />
int<br />
main()<br />
{<br />
	Test3 t3;<br />
<br />
	return 0;<br />
}


Before Test3 can be initialized, Test1 and Test2 must be initialized. To Initialize Test1, you have to construct its base classes. The first base class of Test1 is Base0. Therefore, I would expect that the constructor for Base0 to be the first constructor called. However, my output shows that the first construct called is Base1. I do not understand why. I am hoping that somebody can tell me why?

Thanks
Bob
AnswerRe: A Question about Constructors Pin
led mike20-Nov-08 8:55
led mike20-Nov-08 8:55 
AnswerRe: A Question about Constructors Pin
Venkata Rama Subbarao20-Nov-08 9:08
Venkata Rama Subbarao20-Nov-08 9:08 
QuestionNeed Help in Read a file at compilation time to initialize variable Pin
scamguru20-Nov-08 7:16
scamguru20-Nov-08 7:16 
AnswerRe: Need Help in Read a file at compilation time to initialize variable Pin
Code-o-mat20-Nov-08 7:28
Code-o-mat20-Nov-08 7:28 
GeneralRe: Need Help in Read a file at compilation time to initialize variable Pin
scamguru20-Nov-08 7:30
scamguru20-Nov-08 7:30 
GeneralRe: Need Help in Read a file at compilation time to initialize variable Pin
toxcct20-Nov-08 7:38
toxcct20-Nov-08 7:38 
QuestionDefinitive Direct3D example Pin
Jim Crafton20-Nov-08 7:09
Jim Crafton20-Nov-08 7:09 
AnswerRe: Definitive Direct3D example Pin
Code-o-mat20-Nov-08 7:19
Code-o-mat20-Nov-08 7:19 
GeneralRe: Definitive Direct3D example Pin
Jim Crafton20-Nov-08 7:29
Jim Crafton20-Nov-08 7:29 
GeneralRe: Definitive Direct3D example Pin
Code-o-mat20-Nov-08 7:58
Code-o-mat20-Nov-08 7:58 
GeneralRe: Definitive Direct3D example Pin
cmk20-Nov-08 12:39
cmk20-Nov-08 12:39 
QuestionProbem with Directory Settings - Read Only Pin
Larry Mills Sr20-Nov-08 6:47
Larry Mills Sr20-Nov-08 6:47 
AnswerRe: Probem with Directory Settings - Read Only Pin
Venkata Rama Subbarao20-Nov-08 9:18
Venkata Rama Subbarao20-Nov-08 9:18 
QuestionC++ destructor problem Pin
Fred Andres20-Nov-08 4:44
Fred Andres20-Nov-08 4:44 
AnswerRe: C++ destructor problem Pin
Cedric Moonen20-Nov-08 4:57
Cedric Moonen20-Nov-08 4:57 
GeneralRe: C++ destructor problem Pin
Fred Andres20-Nov-08 5:07
Fred Andres20-Nov-08 5:07 
QuestionRe: C++ destructor problem Pin
David Crow20-Nov-08 5:05
David Crow20-Nov-08 5:05 

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.