Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class Person{
- public:
- Person(){
- this->name = "Unset";
- this->age = 0;
- }
- Person(std::string name, int age) {
- this->name = name;
- this->age = age;
- }
- std::string name;
- int age;
- };
- int main()
- {
- Person * arr = new Person[3];
- arr[0] = Person("Pesho", 12);
- arr[1] = Person("Gosho", 14);
- arr[2] = Person("Pencho", 20);
- for (int i = 0; i < 3; i++)
- {
- std::cout << arr[i].name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement