#include <iostream>
usingnamespace std;
class Goat {
public:
Goat(string name, int age);
Goat();
void rest() const;
void bleat() const;
string getName() const;
int getAge() const;
private:
string name;
int age;
};
Goat::Goat() {
name = "Kid";
age = 0;
}
void Goat::rest() const {
cout << "zZzZzZz" << endl;
}
void Goat::bleat() const {
cout << "Meeh-eh-eh!" << endl;
}
int main() {
Goat myGoat;
cout << "Meet my new goat";
myGoat.getName();
cout << "He plays with his mother, a 9 year old Goat named Nanny." << endl;
cout << "My new goat Kid knows three things: " << endl;
cout << "1. How to eat. Show them Kid: Chomp, burp!" << endl;
cout << "2. How to bleat. Show them Kid: ";
myGoat.bleat();
cout << "3. How to rest. Show them Kid: ";
myGoat.rest();
return 0;
}
xxvms okay i got it , idk what i was thinking, basically i wanted it to print the goats name kid without using a literal cout cout << "Kid"; in line 34, so now I've just changed it to
1 2 3
void Goat::getName() const {
cout << name;
}
haha idk how that flew right over me , everything is working great now :D thanks for everyone's input!:)