Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Dog {
- private:
- string name;
- int age;
- string color;
- public:
- Dog(){
- name = "";
- age = 0;
- color = "";
- }
- Dog(string name, int age, string color){
- this->name = name;
- this->age = age;
- this->color = color;
- }
- string getName() { return name; }
- void bark(){
- cout << name << " is barking!.." << endl;
- }
- void bark(Dog d){
- cout << name << " is barking at " << d.getName() << "... !" << endl;
- }
- void bark(Dog d1, Dog d2){
- cout << name << " is barking at " << d1.getName()
- << " and " << d2.getName() << "... !" << endl;
- }
- };
- class Cat {
- private:
- string name;
- int age;
- string color;
- public:
- Cat(){
- name = "";
- age = 0;
- color = "";
- }
- Cat(string name, int age, string color){
- this->name = name;
- this->age = age;
- this->color = color;
- }
- string getName() { return name; }
- void scratch(){
- cout << name << " is barking!.." << endl;
- }
- void scratch(Dog d){
- cout << name << " is scratching " << d.getName() << "... !" << endl;
- }
- void scratch(Dog d, Cat c){
- cout << name << " is scratching " << d.getName()
- << " and " << c.getName() << "... !" << endl;
- }
- };
- //----------------------------------------------- MAIN
- int main() {
- cout << "\n\n";
- Dog d1("Pluto", 3, "Brown");
- Dog d2("Max", 2, "Black");
- Dog d3("Lucy", 13, "White");
- Cat c1("Mini", 1, "Gray");
- Cat c2("Daisy", 2, "Yellow");
- d1.bark();
- d2.bark();
- d1.bark(d2);
- d2.bark(d1);
- d3.bark(d2, d1);
- c1.scratch(d1, c2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement