C++ programs should probably use
std::cout
rather than
printf
. In this case, the format specifier '%s' expects an
char *
not a C++
string
.
You should get the right results with
std::cout << "Name: " << person->getName() << " Age: " << person->getAge() << std::endl;