operator new

Started by
11 comments, last by Triglav 19 years, 7 months ago
Quote:Original post by Jingo
Quote:Original post by Triglav
...

int main()
{
SnakesRoom room1(); // nice
return 0;
}



SnakesRoom room1(); is actually a function declaration, it doesnt create an instance of SnakesRoom .

SnakesRoom room1; //nicer

:)

in my example it does
Triglav - Member of TAJGA Team
Advertisement
Doesn't :/.

Run this modified version of the code, you wont get the constructor message, it will never be called, as you are not creating an instance.

#include <iostream>			#include <windows.h>	#include <string>	using namespace std; // this line is really shitty, use "using cout" insteadclass CItem{  // your CItem object};class SnakesRoom : public CItem{  // your SnakesRoom object  SnakesRoom (){     std::cout << "Constructor Called";  }};int main(){	SnakesRoom room1(); // nice	return 0;}
Quote:Original post by Jingo
Doesn't :/.

Run this modified version of the code, you wont get the constructor message, it will never be called, as you are not creating an instance.

*** Source Snippet Removed ***


I'm sorry but this is not my computer and there is no compiler. however, I trust you, probably you know why are you saying that. [wink]
Triglav - Member of TAJGA Team

This topic is closed to new replies.

Advertisement