|
-
March 19th, 2011, 07:06 AM
#1
creating variables on the stack
Can some please show me , how to create class instances on the stack , the ones I am interested in are the ones which need to have arguments passed on the constructor ,
I use QT as C++ dev environment ,
Code:
QString mystring; // that is good , as you can see the class instance do not require a argument to be // passed on to the constructor
// how to do this in the header file
QPainter mypainter(this);
when ever their is a argument to be passed passed on the constructor I end up doing this;
QPainter *mypainter; // in the header
and then in CPP file
mypianter = new QPainter(this);
I was wondering if there was a way to this on the stack as oppose to the heap.
saves me the trouble of deteting the class instance later
as in
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|