Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Computer
  5. {
  6. private:
  7.     int inventarNummer;
  8.     char* osName;
  9.     int zustand;
  10. public:
  11.     Computer(){};
  12.     Computer(int a, char *b, int c){
  13.         inventarNummer = a;
  14.         osName = b;
  15.         zustand = c;
  16.     }
  17.     Computer(const Computer &c){
  18.         inventarNummer = c.inventarNummer;
  19.         osName = c.osName;
  20.         zustand = c.zustand;
  21.     }
  22.     void info(){
  23.         cout<<inventarNummer<<" "<<osName<<" "<<zustand<<endl; 
  24.     }
  25.     Computer operator=(Computer c){
  26.         Computer temp;
  27.         temp.inventarNummer = c.inventarNummer;
  28.         temp.osName = c.osName;
  29.         temp.zustand = c.zustand;
  30.         return temp;
  31.     }
  32. };
  33.  
  34. int main()
  35. {
  36.     Computer o1(10,(char*)"MacOS",0);
  37.     Computer o2(o1);
  38.     Computer *o3;
  39.     Computer *o4;
  40.     o3 = new Computer(15,(char*)"Windows",1);
  41.     o4 = new Computer;
  42.     o4 = o3;
  43.     o1.info();
  44.     o2.info();
  45.     o3->info();
  46.     o4->info();
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement