Хорошо. Итак, я попробовал все.У меня есть класс ниже, и у меня есть драйвер, который будет читать файл и получать весь контент, используя getline, и копировать его в виде строки.
В моем драйвере у меня также есть vector<Seminar>
.
Что меня смущает, так это КАК поместить мои данные из строки в вектор.Теперь я думал, что, может быть, сначала мне нужно сделать конструктор и т. Д., Чтобы это работало?
Не могу реализовать это правильно.
class Seminar
{
public:
Seminar(int number = 0, string date = "yyyy-mm-dd" , string title = "")
{
Number = number;
Date = date;
Title = title;
}
int get_number() const {return Number; }
string get_date() const {return Date; }
string get_title() const {return Title; }
private:
int Number; // Seminar number
string Date; // Date of Seminar
string Title; // Title of Seminar
};
enter code here
vector<Seminar> all;
main()
ifstream InFile;
string Letter;
string File;
cout << "Type Letter from the Menu: "<<endl;
cin >> Letter;
if (Letter == "A" || "a")
{
cout << "What is the file you would like to read: "<<endl;
cin >> File;
InFile.open(File.c_str(),ios::in);
if(InFile)
{
string line = "";
while(getline(InFile,line))
{
cout << line << endl;
}
InFile.close();
}
}`enter code here`