Скачиваний:
12
Добавлен:
01.05.2014
Размер:
1.02 Кб
Скачать
#if !defined(SHAPE_H)
#define SHAPE_H

#include <iostream>
using namespace std;

class Shape {
	private:
	    static unsigned long int count;

		static unsigned long int total;

		const unsigned long int id;

	public:
		Shape(): id(++total){	
			count++;
			cout << "create Shape#" << id << endl; 
		};
		//virtual ~Shape() = 0;
		virtual ~Shape() { 
			count--;
			cout << "destroy Shape#" << id << endl; 
		}
	
		virtual void moveBy(const double x, const double y) = 0;
		//virtual void moveBy(const double x, const double y) {};

		virtual ostream& print(ostream& os) const = 0;
		//virtual ostream& print(ostream& os) const { return os;};
		
		friend ostream& operator<<(ostream& os, const Shape* o) {
			return o->print(os);
		}

		friend ostream& operator<<(ostream& os, const Shape& o) {
			return o.print(os);
		}

		unsigned long int getObjectId() const{
			return id;
		}

		static unsigned long int getNumberOfObjects(){ //const
			return count;
		}
};

#endif 
Соседние файлы в папке lab2_2