Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. struct vec3d {
  7.     float x, y, z;
  8.     void print(){
  9.         cout << x << " " << y << " " << z << endl;
  10.     }
  11.     vec3d add (vec3d a){
  12.         vec3d b;
  13.         b.x=x+a.x;
  14.         b.y=y+a.y;
  15.         b.z=z+a.z;
  16.         return b;
  17.     }
  18. };
  19.  
  20. #include <string>
  21. /*
  22. struct Dog {
  23.     //properties
  24.     string name;
  25.     bool home;
  26.     // constructors
  27.     Dog(string name_) {
  28.         name = name_;
  29.         home = true;
  30.     }
  31.     Dog() {
  32.         name = "Homeless";
  33.         home = false;
  34.     }
  35.     // methods
  36.     void bark(){
  37.         if (home) {
  38.             cout << "Woof! My name is " << name << endl;
  39.         }
  40.         else {
  41.             cout << "Woof! I am homeless" << endl;
  42.         }
  43.     }
  44. };
  45. */
  46. struct Cat {
  47.     string name;
  48.     Cat (string name_){
  49.         name = name_;
  50.     }
  51.     void m(){
  52.         cout << " "
  53.     }
  54. };
  55.  
  56. int main(int argc, char *argv[]){
  57.     /*
  58.     vec3d a;
  59.     a.x = 4;
  60.     a.y = 1;
  61.     a.z = 9;
  62. */
  63.     Dog d("Dusty");
  64.     d.bark();
  65.     Dog f("Fluffy");
  66.     f.bark();
  67.     Dog g;
  68.     g.bark();
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement