954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Instantiating class

Is this two ways of instantiating class both acceptable?(My intention is to create CBox on stack instead of heap)


CBox a=CBox(1);
CBox b(2);

Definition of CBox is as followed:

class CBox
{
public:
	int abc;
	CBox(int var){
		abc=var;
	}
	
};
jack1234
Newbie Poster
11 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Are you new ing? If so, that object is on the 'heap'.

Are you instantiating an object within a function? If so, that object is on the 'stack'.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You