Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
17
Добавлен:
01.05.2014
Размер:
786 б
Скачать
	// source module: friend.C

	#include <iostream.h>
	int year;

	class foo;

	class dates {

			friend ostream& operator<<(ostream&,dates&);

			int year, month, day;

		public:

			friend class foo;

			dates() { year=month=day = 0; };

			~dates() {};

			int sameDay(int d) const { return d==day; };

			void set(int y) const { ::year = y; };

			void set(int y) { year = y; };

	};



	class foo {

		public:

			void set(dates& D, int  year) {D.year = year; };

	};



	ostream& operator<< (ostream& os, dates& D)

	{

		os << D.year << " ," << D.month << " ," << D.day;
		return os;

	}



	int main() {

			dates Dobj;

			foo Fobj;

			Fobj.set(Dobj, 1998);

			clog << "Dobj: " << Dobj << '\n';
			return 0;

		}
Соседние файлы в папке ch2