Тема: Класи С++
#include <iostream>
#include<string>
#include<fstream>
using namespace std;
class BusTicket
{
private:
int number;
int last_name;
protected:
string control;
string day_sell_ticket;
string time_sell_ticket;
string place_sell_ticket;
string point_of_departure;
string point_of_destination;
string day_of_departure;
string time_of_departure;
string day_of_arrival;
string time_of_arrival;
string bus_number;
string intermediate_stopping_points;
string place_number;
string baggage;
public:
string name;
BusTicket();
BusTicket(string control, string day_sell_ticket, string time_sell_ticket, string place_sell_ticket, string point_of_departure,
string point_of_destination, string day_of_departure, string time_of_departure, string day_of_arrival, string time_of_arrival,
string bus_number, string intermediate_stopping_points, string place_number, string baggage, int number, int last_name);
~BusTicket();
/*BusTicket(const BusTicket& );*/
void get_information()
{
cout << "Day sell ticket" << endl;
cin >> day_sell_ticket;
cout << "Time sell ticket " << endl;
cin >> time_sell_ticket;
cout << "Place sell ticket" << endl;
cin >> place_sell_ticket;
cout << "Point of departure" << endl;
cin >> point_of_departure;
cout << "Point of destination" << endl;
cin >> point_of_destination;
cout << "Day of departure" << endl;
cin >> day_of_departure;
cout << "Time of departure" << endl;
cin >> time_of_departure;
cout << "Day of arrival" << endl;
cin >> day_of_arrival;
cout << "Time of arrival" << endl;
cin >> time_of_arrival;
cout << " Bus number" << endl;
cin >> bus_number;
cout << "Intermediate stopping points" << endl;
cin >> intermediate_stopping_points;
cout << " Place number" << endl;
cin >> place_number;
cout << "Baggage" << endl;
cin >> baggage;
}
void show_information()
{
cout << "Day sell ticket" << day_sell_ticket << endl;
cout << "Time sell ticket " << time_sell_ticket << endl;
cout << "Place sell ticket" << place_sell_ticket << endl;
cout << "Point of departure" << point_of_departure << endl;
cout << "Point of destination" << point_of_destination << endl;
cout << "Day of departure" << day_of_departure << endl;
cout << "Day of arrival" << day_of_arrival << endl;
cout << "Time of arrival" << time_of_arrival << endl;
cout << " Bus number" << bus_number << endl;
cout << "Intermediate stopping points" << intermediate_stopping_points << endl;
cout << " Place number" << place_number << endl;
cout << "Baggage" << baggage << endl;
}
void save_file(fstream& fout, BusTicket ticket)
{
if (!fout.is_open())
{
cout << "Defeat" << endl;
}
else
{
fout << ticket.name;
}
fout.close();
}
void read_from_file(fstream& fin, BusTicket ticket)
{
if (!fin.is_open())
{
cout << "Defeat" << endl;
}
else
{
fin >> ticket.name;
}
fin.close();
}
};
int main()
{
BusTicket ticket;
BusTicket* t = &ticket;
ticket.get_information();
ticket.show_information();
string path = "BusTicket.txt";
ofstream fout;
fout.open(path, ofstream::app);
void save_file(fstream & fout, BusTicket ticket);
ofstream fin;
void read_from_file(fstream & fin, BusTicket ticket);
return 0;
}
Мені потрібно зберегти обєкти класу у файл,і вивести з файлу.Програма не працює.