ex4-11.cpp - Example 4-11 Constructor Initialization List

// File: ex4-11.cpp

#include <iostream>
using namespace std;

class xyz
{
private:
	int a, b, c;
public:
	xyz() : a(1), b(2), c(3)	// default constructor�
	{
	} 

	xyz(int, const xyz&); // constructor prototype�

	void print(void)
	{
		cout << a << b << c << endl;
	}
};

xyz::xyz(int aa, const xyz& hey) : a(aa), b(5), c(hey.c)
{
}

int main(void)
{
	xyz yo;
	xyz yoyo(2, yo);
	yo.print();
	yoyo.print();
	return 0;
}



CIS27: Programming in C++    Instructor: Joe Bentley