Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Movie
  4. {
  5. public:
  6.     Movie()
  7.     {
  8.     }
  9.     Movie(const char* name)
  10.     {
  11.         this->name = (char*)name;
  12.     }
  13.     ~Movie()
  14.     {
  15.         std::cout << "Destructor called" << std::endl;
  16.         delete[] name;
  17.     }
  18.     void SetName()
  19.     {
  20.         name = new char[100];
  21.         std::cin >> name;
  22.     }
  23.  
  24.     char* GetName() const
  25.     {
  26.         return name;
  27.     }
  28.  
  29.    
  30. private:
  31.     char* name;
  32. };
  33.  
  34. int main()
  35. {
  36.    
  37.     Movie movie("Star Wars");
  38.  
  39.     std::cout << movie.GetName();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement