Как реализовать вовод в поток класса, вектора переменной C++
#ifndef LINE_H
#define LINE_H
#include <string>
#include <vector>
#include <iostream>
#include <istream>
struct Date {
int day{ 01 };
int month{ 01 };
int year{ 1999 };
Date(int day, int month,int year ) {
this->day = day;
this->month = month;
this->year = year;
}
Date() = default;
friend std::istream& operator >>(std::istream& is, Date& date) {
is >> date.day >> date.month >> date.year;
return is;
}
friend std::ostream& operator <<(std::ostream& os, Date& date) {
os << date.day << "." << date.month << "." << date.year;
return os;
}
};
class letter;
class Email {
std::vector<letter> letters;
public:
std::string userName{ "None" };
Email(std::string userName) ;
Email() = default;
friend std::istream& operator >>(std::istream& is, Email& mail) {
is >> mail.userName;
return is;
}
friend std::ostream& operator<<(std::ostream& os, Email& mail) {
os << "Имя пользователя: " << mail.userName << std::endl;
os << "Содержимое вектора letters:" << std::endl;
for (const letter& letterObj : mail.letters) {
os << "Отправитель: " << letterObj.sender.userName << std::endl;
os << "Сообщение: " << letterObj.message << std::endl;
os << "Дата: " << letterObj.when << std::endl;
os << std::endl;
}
return os;
}
std::vector<letter>& getLetters() {
return letters;
}
void setLetters(const std::vector<letter>& newLetters) {
letters = newLetters;
}
};
class letter {
Email sender;
std::string message;
Date when;
public:
letter() = default;
letter(std::string userName, std::string message, Date when);
friend std::istream& operator>>(std::istream& is, letter& mes) {
std::string email;
is >> email;
char quote;
is >> std::ws >> quote;
std::getline(is, mes.message, '"');
is >> mes.when;
return is;
}
};
#endif
В классе Email нужно реализовать вывод в поток мой вектор letters