Advertisement
irmantas_radavicius

Untitled

Mar 23rd, 2022
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. class Animal{
  6.  
  7.     public:
  8.         Animal(string aname, string asex, int aage, bool asociable, bool apatronage){
  9.             cout <<"This is the default constructor"<<endl;
  10.             name = aname;
  11.             sex = asex;
  12.             age = aage;
  13.             sociable = asociable;
  14.             patronage = apatronage;
  15.         }
  16.  
  17.         ~Animal(){
  18.             cout<< "This is a destructor";
  19.         }
  20.  
  21.         void display(){
  22.             cout<<"The name of the animal is: " <<name <<endl;
  23.             cout<<"The sex of the animal is: " <<sex <<endl;
  24.             cout<<"The age of the animal is: " <<age <<endl;
  25.             cout<<"The animal is sociable : " <<sociable <<endl;
  26.             cout<<"The animal is patronaged: " <<patronage <<endl;
  27.         }
  28.  
  29.     private:
  30.         //data of the animal
  31.         string name;
  32.         string sex;
  33.         int age;
  34.         bool sociable;
  35.         bool patronage;
  36. };
  37.  
  38. int main(){
  39.  
  40.     Animal a("Curro", "Male", 2, true, false);
  41.     a.display();
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement