I was wondering how I can print an instance of a class I've created to console?
The class I've created:
class Person
{
private:
string surname;
string forename;
int age;
public:
Person(string surname, string forename, int age) :surname(surname), forename(forename), age(age) { }
void getSurname();
void getForename();
void getAge();
};
Creating the instance:
int main()
{
std::string testSurname{ "RandomSurname" };
std::string testForename{ "RondomForename" };
std::string testAge{ "1" };
int testAgeInt = std::stoi(testAge);
Person somePerson{ testSurname, testForename, testAgeInt };
}
How can I print that last line to console?
I've attempted using the obvious:
cout << somePerson;
But I get a "no operator '<<' matches these operands" error.