ex4-16.cpp - Example 4-16 Containment and constructors

#include <iostream>
using namespace std;
class One
{
    int member;
public:

    One()
    {
        cout << "One default ctor called\n";
    }

    One(int j) : member(j)
    {
        cout << "One second ctor called" << endl;
    }
};

class Two
{
    One member;
public:

    Two()
    {
        cout << "Two default ctor called" << endl;
    }

    Two(int k) : member(k)
    {
        cout << "Two second ctor called" << endl;
    }
};

int main()
{
    cout << "declare object1" << endl;
    Two object1;
    cout << "declare object2" << endl;
    Two object2(5);
    return 0;
}



CIS27: Programming in C++    Instructor: Joe Bentley