Yurttas/PL/OOL/Cplusplus/F/04/02/03/00/Birds.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   Birds.cpp
14*/
15
16
17#include <cstring>
18
19#include <iostream>
20
21using namespace std;
22
23#include "Birds.h"
24
25Birds::
26Birds() : Animal(),
27          fly(true) {
28}
29
30Birds::
31Birds(const Birds& a) : Animal(a),
32                        fly(a.fly) {
33}
34
35Birds::
36~Birds() {
37}
38
39Birds&
40Birds::
41operator=(const Birds& 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  fly = a.fly;
52
53  return *this;
54}
55
56bool
57Birds::
58get_fly() const {
59  return fly;
60}
61
62void
63Birds::
64set_fly(const bool a) {
65  fly = a;
66}
67
68void
69Birds::
70print() const {
71  cout << "Name: " << name << endl;
72  cout << "Age: " << age << endl;
73  cout << "Fly: " << fly << endl;
74  cout << endl;
75}