Tuesday, 7 May 2013

Week eight day 3

This was an interesting learning curve for C++,
#include <iostream>
class Cat
{
    public:
        int GetAge();
        void SetAge(int age);
        void Meow();
    private:
        int itsAge();
};

int Cat::GetAge()
{
    return itsAge();
}

void Cat::SetAge(its age)
{  itsAge = age); }

void Cat::Meow();
{ cout << "Meow!"; }

int main()
{
    Cat Frisky;
    Frisky.SetAge(5);
    Frisky.Meow();
    std::cout << "Frisky is a cat who is ";
    std::cout << Frisky.GetAge() << " years old\n";
    Frisky.Meow();
    return 0;
}

No comments:

Post a Comment