I'm trying to output the values of a vector array into a text but im getting this weird error
no opeartor "<<" matches the operands, operand types are : std::ofstream << Person
Here is my code
class Person {
public:
Person(string, string, int);
string get_name() {
return name;
}
string get_family() {
return family;
}
int get_age() {
return age;
}
private:
string name;
string family;
int age;
};
ofstream myfile;
myfile.open("test.txt");
vector <Person> persons;
string N, F;
int A;
while (cin >> N >> F >> A) {
Person tmpPerson(N, F, A);
persons.push_back(tmpPerson);
for (int i = 0; i < persons.size(); i++){
myfile << persons[i] << " " << endl;
}
myfile.close();
};
I have incuded the and tried everything, but this error, persist, would be very thankful for some help !