Yurttas/PL/OOL/Cplusplus/F/04/02/03/00/Mammals.cpp
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 Mammals.cpp
14*/
15
16
17#include <cstring>
18
19#include <iostream>
20
21using namespace std;
22
23#include "Mammals.h"
24
25Mammals::
26Mammals() : Animal(),
27 legs(2) {
28}
29
30Mammals::
31Mammals(const Mammals& a) : Animal(a),
32 legs(a.legs) {
33}
34
35Mammals::
36~Mammals() {
37}
38
39Mammals&
40Mammals::
41operator=(const Mammals& a) {
42 if(this==&a) return *this;
43
44 delete [] name;
45
46 name = new char[strlen(a.name)+1];
47 strcpy(name, a.name);
48
49 age = a.age;
50
51 legs = a.legs;
52
53 return *this;
54}
55
56int
57Mammals::
58get_legs() const {
59 return legs;
60}
61
62void
63Mammals::
64set_legs(const int a) {
65 legs = a;
66}
67
68void
69Mammals::
70print() const {
71 cout << "Name: " << name << endl;
72 cout << "Age: " << age << endl;
73 cout << "Legs: " << legs << endl;
74 cout << endl;
75}