// File: ex4-6.cpp - test when a constructor is called

#include <iostream>
using namespace std;

class Z
{
  public:
    Z() { cout << "Z's constructor is called now" << endl;}
};

int main()
{
  cout << "\n1. Is the constructor called?\n";
  Z z;                          // declare a Z

cout << "\n2. Is the constructor called?\n";
Z bunch[5]; // declare a bunch of Zs
cout << "\n3. Is the constructor called?\n";
Z* ptrZ; // declare a pointer to Z
cout << "\n4. Is the constructor called?\n";
Z* a_new_prtZ = new Z; // allocate memory for a Z
cout << "\n5. Is the constructor called?\n";
Z* threeZ = new Z[3]; // allocate memory for 3 Zs
cout << "\n6. Is the constructor called?\n";
Z** ptr_ptr_Z; // declare a ptr to ptr to a Z
cout << "\n7. Is the constructor called?\n";
Z** ptr_ptr_newZ = new Z*; // allocate memory for a ptr to ptr to a Z }