|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
26.12.2009, 20:54 | #1 |
Регистрация: 19.09.2009
Сообщений: 4
|
Классы
Помогите пожалуйста!
В классе train(поезд) надо создать виртуальную функцию. А в классе рtrain(пассажирский поезд) сделать перегрузку! Как это сделать? Код ниже. class train { private: int wcount; // kolichestvo vagonov poezda std::string name; // imya poezda public: int get_wcount () const { return wcount ;} std::string get_name() const { return name ;} void set_wcount(int _wcount) {wcount=_wcount ;} void set_name(std::string _name) {name=_name ;} virtual std::string mktext(); friend std:stream& operator<<(std:stream& os, const train _train); virtual ~train(); }; class ptrain : public train { private: int maxpass, wres; // max kol-vo pasazhirov, kol-vo vagonov-restoranov std::string type ; // tip poezda public: int get_maxpass() const { return maxpass ;} int get_wres() const { return wres ;} std::string get_type() const {return type ;} void set_maxpass(int _maxpass) { maxpass= _maxpass;} void set_wres(int wres) { wres = _wres ;} void set_type(std::string _type) { type = _type ;} friend std:stream& operator<<(std:stream& os, const ptrain _ptrain); virtual std::string mktext(); ptrain(); ptrain(const ptrain & _ptrain); // copy contructor ptrain(int _wcount, int _wres, int _maxpass, const char* _type, const char* _name); ptrain(const char* _name); // conv constructor virtual ~ptrain(); }; |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
классы | Ferghost | Помощь студентам | 3 | 05.06.2009 03:20 |
Классы в С++ | S2S | Общие вопросы C/C++ | 0 | 15.03.2009 13:25 |
Классы С++ | kims | Общие вопросы C/C++ | 2 | 05.03.2009 00:45 |
Классы | Викдон | Общие вопросы C/C++ | 3 | 04.03.2009 23:07 |