Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Cat {
  6.     int EyeColor[3];
  7.     string name;
  8.     void say(){
  9.         cout << "My name is " << name << endl;
  10.     }
  11.     void setName (string new_name){
  12.         name = new_name;
  13.     }
  14.     void setEyeColor (int r, int g, int b){
  15.       eyeColor[2] = b;
  16.       eyeColor[1] = g;
  17.       eyeColor[0] = r;
  18.     }
  19.     string getName(){
  20.         return name;
  21.     }
  22.     int getEyeColor (int index){
  23.         return eyeColor [index];
  24.     }
  25. };
  26.  
  27. int main()
  28. {
  29.     Cat c1;
  30.     c1.setName("Bonnie");
  31.     c1.setEyeColor(0,0,255);
  32.     cout << c1.getName();
  33.     int r = c1.getEyeColor(0);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement