ex4-8.cpp - Example 4-8 When is a constructor called? (3)

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

#include <iostream>
using namespace std;

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

	 Z(const Z& zed)
	 {
	   cout << "Z's copy constructor is called now" << endl;
	 }

	 ~Z()
	 {
		cout << "Z's destructor is called now" << endl;
	 }
};

Z funk1(Z hey)
{
  cout << "This is funk1\n";
  return hey;
}

int main(void)
{
  Z temp;
  funk1(temp);
  return 0;
}



CIS27: Programming in C++    Instructor: Joe Bentley