Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,265 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,504 people online right now. Registration is fast and FREE... Join Now!




CLASSES

 
Reply to this topicStart new topic

CLASSES, Can someone show me how to Show the order of constructor and destructo

allican57
13 Dec, 2006 - 01:25 PM
Post #1

New D.I.C Head
*

Joined: 2 Oct, 2006
Posts: 37


My Contributions
Can someone show me how to Show the order of constructor and destructor calls for the below code?
CODE

class Test
{
public:
    Test(){cout << “constructor”;}
    ~Test(){cout << “destructor”;}
};

Test obj1;

void main()
{
    Test obj2;
    static Test obj3;
}




User is offlineProfile CardPM
+Quote Post

realNoName
RE: CLASSES
13 Dec, 2006 - 01:40 PM
Post #2

D.I.C Regular
***

Joined: 4 Dec, 2006
Posts: 300



Thanked: 5 times
My Contributions
just do somthing like this
CODE


class Test
{
public:
    Test(string name)
        :me(name)
    {
        cout << "constructor " << me << endl;
    }
    ~Test(){
        cout << "destructor " << me << endl;
    }
private:
    string me;
};

Test obj1("obj1");

void main()
{
    Test obj2("obj2");
    static Test obj3("obj3");
}


This post has been edited by realNoName: 13 Dec, 2006 - 01:58 PM
User is offlineProfile CardPM
+Quote Post

allican57
RE: CLASSES
13 Dec, 2006 - 03:01 PM
Post #3

New D.I.C Head
*

Joined: 2 Oct, 2006
Posts: 37


My Contributions
Thanks[quote]
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:26PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month