Constructor and Destructor hw

Feb 9, 2014 at 12:15am
I'm having trouble figuring out what i'm supposed to do. The question states

"Create a new program, order1.cpp , with class , order, that contains only a constructor and a destructor. Determine the order of the constructor and destructor calls for variable by by cout statements inside the constructor and destructor members functions and creating several variable inside main(). To generate a unique identifier for each variable use the keyword this inside the cout statement."

I understand creating a new program, making the class, order, that contains only a constructor and a destructor, and putting the cout statements inside the constructor and destructor. What I don't understand is what I'm suppose to put in the cout statement. If anyone could give me an example what i'm supposed to do would be much appreciated.
Last edited on Feb 9, 2014 at 12:47am
Feb 9, 2014 at 2:52am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

struct A
{
    A() { std::cout << this << " - A::A()\n"; }
    A(const A&) { std::cout << this << " - A::A(const A&)\n"; }
    ~A() { std::cout << this << " - A::~A()\n"; }
};

int main()
{
    {
        A a;
        A b(a);
    }

    A c;
}
Feb 9, 2014 at 2:58am
Thanks
Topic archived. No new replies allowed.