может упоминавшийся ранее клас
Автор admin
Воскресенье, 7 июня 2009 11:32
может упоминавшийся ранее класс Noisy. Этот класс выводит информацию о создании и уничтожении объектов, о присваивании и конструировании копий: //: C07:Noisy.h // Класс для отслеживания основных операций с объектами #ifndef N0ISY_H #define N0ISY_H linclude using endl; using cout; using ostream; class Noisy { static long create, assign, copycons. destroy; long id; public: NoisyO : id(create++) { cout « “d[" « id « "]” « endl: } Noisy(const NoisyS rv) : id(rv.id) { cout « “c[" « id « "]” « endl; ++copycons: } NoisyS operator=(const NoisyS rv) { cout « “(” « id « “)=[" « rv.id « "]” « endl; id = rv.id; ++assign; return *this: } friend bool operator<(const NoisyS lv. const NoisyS rv) { return Iv.id < rv.id: } friend bool operator==(const NoisyS lv. const NoisyS rv) { return lv.id == rv.id; } -NoisyO { cout « “-[" « id « "]” « endl; ++destroy; } friend ostreamS operator«(ostream& os. const Noisy& n) { return os « n.id: } friend class NoisyReport: }: struct NoisyGen { Noisy operatorO О { return NoisyO; } }: // Синглетный класс. Статистика автоматически выводится // при завершении программы: class N
Комментарии закрыты.
Последние комментарии