Ive been given an assignment in college to implement a dog class and to include functionality such as eating,sleeping,barking etc..im not really familiar with writing code to describe living things so just wondering could anyone give me a few suggestions as to how to go about doing this? I know its a strange kinda question but im not looking for code as such, rather suggestions on how to describe the animals behaviour / general design etc.. Any suggestions appreciated


6 Years
Discussion Span
Last Post by oggiemc

Didn't you teacher tell you exactly what to implement, or did he expect you to design the class by yourself?

Describe the attributes of livig things just like you would the attributes of non-living things. You are human (I assume :) ) and have probably observed many times how dogs behave. It doesn't matter what kind of dog it is they all behave the same way. All (or most) dogs bark, so give the dog class a speak() method and make it bark

class dog
   void speak() { cout << "Bark!\n"; }

You can do similar with other attributes, such as eat

chass dog
   void eat() {cout << "Chomp, chomp!\n";}

For your purpose it doesn't matter if it's silly or not as long as you make the class do what dogs normally do.

Edited by Ancient Dragon: n/a


thanks for reply Ancient Dragon,

we werent given explicit implementations.. It was more the purpose of demonstrating knowledge of various topics in C++ (such as funtion overriding, operator overloading, dynamic binding etc)..i was finding it hard to come up of ways of demonstrating these topics through an animal class and finding it hard.. he said we cud pick our own class instead of the examples he gave us so im trying to think of a better class to implement instead (ps we are not allowed to use bank accounts/cars/college personnel classes either as these are in notes)do you have any suggestions of other classes? as there doesnt seem to be much i can demonstrate through the actions of an animal?! Thanks again

Edited by oggiemc: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.