Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Person{
  5. public:
  6.     Person(){
  7.         this->name = "Unset";
  8.         this->age = 0;
  9.     }
  10.     Person(std::string name, int age) {
  11.         this->name = name;
  12.         this->age = age;
  13.     }
  14.     std::string name;
  15.     int age;
  16. };
  17.  
  18. int main()
  19. {
  20.     Person * arr = new Person[3];
  21.     arr[0] = Person("Pesho", 12);
  22.     arr[1] = Person("Gosho", 14);
  23.     arr[2] = Person("Pencho", 20);
  24.  
  25.     for (int i = 0; i < 3; i++)
  26.     {
  27.         std::cout << arr[i].name;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement