Skip to content

Instantly share code, notes, and snippets.

@mhassanist
Created January 12, 2021 07:29
Show Gist options
  • Save mhassanist/fdeff7b648468f88f7619f3a42365c0e to your computer and use it in GitHub Desktop.
Save mhassanist/fdeff7b648468f88f7619f3a42365c0e to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
class Cat
{
string name;
string breed;
int age;
public:
void setName(string nameIn);
void setBreed(string breedIn);
void setAge(int ageIn);
string getName();
string getBreed();
int getAge();
void printInfo();
};
void Cat::setName(string nameIn)
{
name = nameIn;
}
void Cat::setBreed(string breedIn)
{
breed = breedIn;
}
void Cat::setAge(int ageIn)
{
age = ageIn;
}
string Cat::getName()
{
return name;
}
string Cat::getBreed()
{
return breed;
}
int Cat::getAge()
{
return age;
}
void Cat::printInfo()
{
cout<<name<<" "<<breed<<" "<<age;
}
int main()
{
Cat cat1,cat2;
cat1.setName("Kimmy");
cat2.setName("Bobby");
cat1.setBreed("calico");
cat2.setBreed("main coon");
cat1.setAge(4);
cat2.setAge(1);
cat1.printInfo();
cout<<"\n";
cat2.printInfo();
cout<<"\n\n";
//Alternate printing method
cout<<cat1.getName()<<" "<<cat1.getBreed()<<" "<<cat1.getAge()<<"\n";
cout<<cat2.getName()<<" "<<cat2.getBreed()<<" "<<cat2.getAge();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment