-
Notifications
You must be signed in to change notification settings - Fork 0
/
v33.cpp
54 lines (44 loc) · 1.01 KB
/
v33.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: v33.cpp
* Author: SerG1oAC
*
* Created on February 21, 2016, 5:44 PM
*/
#include <cstdlib>
#include <iostream>
using namespace std;
class Mamifero
{
public:
Mamifero():edad(1){cout << "Constructor Mamifero\n";}
virtual ~Mamifero(){cout << "Destructor Mamifero\n";}
virtual void hablar()const {cout << "Mamifero hablando\n";}
protected:
int edad;
};
class Gato: public Mamifero
{
public:
Gato(){ cout << "Constructor Gato\n";}
~Gato(){cout << "Destructor Gato\n";}
void hablar() const {cout << "Miauuuuu\n";}
void ronronear() const {cout << "Rrrrrrrr\n";}
};
/*
*
*/
int main(int argc, char** argv) {
Mamifero *pGato = new Gato;
pGato->hablar();
Gato *pelGato = dynamic_cast<Gato *>(pGato);
if(pelGato)
{
pelGato->ronronear();
}
return 0;
}