Yurttas/PL/OOL/Cplusplus/F/04/02/03/00/animals 01.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2001
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : June 1, 2001.
11   author : Salih Yurttas.
12
13   animals_01.cpp
14*/
15
16
17#include <iostream>
18
19using namespace std;
20
21#include "Animal.h"
22#include "Mammals.h"
23#include "Birds.h"
24#include "Land.h"
25#include "Sea.h"
26
27int main(int argc, char* argv[]) {
28
29  Animal* a0 = new Animal;
30
31  cout << "Default construction of Animal: " << endl;
32  a0->print();
33
34  a0->set_name("A0");
35  a0->set_age(7);
36
37  cout << "After set members of an Animal: " << endl;
38  a0->print();
39
40  cout << endl;
41
42  a0 = new Mammals;
43
44  cout << "Default construction of a Mammal: " << endl;
45  a0->print();
46
47  a0->set_name("M0");
48  a0->set_age(1);
49
50  cout << "After set members of a Mammal: " << endl;
51  a0->print();
52
53  cout << endl;
54
55  a0 = new Birds;
56
57  cout << "Default construction of a Bird: " << endl;
58  a0->print();
59
60  a0->set_name("B0");
61  a0->set_age(2);
62
63  cout << "After set members of a Bird: " << endl;
64  a0->print();
65
66  a0 = new Land;
67
68  cout << "Default construction of a Land Mammal: " << endl;
69  a0->print();
70
71  a0->set_name("L0");
72  a0->set_age(1);
73
74  cout << "After set members of Land Mammal: " << endl;
75  a0->print();
76
77  a0 = new Sea;
78
79  cout << "Default construction of a Sea Mammal: " << endl;
80  a0->print();
81
82  a0->set_name("S0");
83  a0->set_age(2);
84
85  cout << "After set members of Sea Mammal: " << endl;
86  a0->print();
87
88}