|
Вопрос # 6 377/ вопрос открыт / |
|
Приветствую, уважаемые эксперты!
Implement classes animal and dog such that you will get the following output from this main:
#include<iostream>
#include "animal.h"
#include "dog.h"
using namespace std;
int main(){
//Direct access
animal a;
a.setName("Tuzik");
a.setSound("Gaf");
cout<<a.getName()<<" "<<a.getSound()<<endl;
//Indirect access
animal *ptr = &a;
ptr->setName("Kisa");
ptr->setSound("Myau");
cout<<ptr->getName()<<" "<<endl;
//output of animal objects
animal s("Shok", "mmm");
cout<<s;
//Inheritance
animal *p = new dog();
p->setName("Tyson");
p->setSound("RRR");
//cout<<p->getName();
//Polymorphism
cout<<p->getName();
return 0;
}
//Expected output:
Tuzik Gaf
Kisa
Shok mmm
Tysonis a dogPress any key to continue . . .
Мини-форум вопроса
Всего сообщений: 1; последнее сообщение — 27 февраля 2013, 12:22; участников в обсуждении: 1.
|
Толяныч (статус: 4-ый класс), 27 февраля 2013, 12:22 [#1]:
Так в чем вопрос ?
|
18 марта 2013, 21:50: Вопрос перемещён в корзину модератором Ерёмин А.А.. Причина: Забыли задать вопрос?
Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте.
|