c++ - why my main function couldn't return at last? -
i build win32 console application program, here source code:
#include <iostream> #include <fstream> #include <vector> #include <string> using namespace std; struct cpassenger { string name; string id; string seat; }; struct cflight { string flnum; string destination; int amount; int booking; string departuretime; string falltime; vector<cpassenger> list; }; class cflightsystem { public: cflightsystem(); ~cflightsystem(); private: vector<cflight> flight; }; cflightsystem::cflightsystem() { ifstream infile("flight.txt"); if(!infile) { cerr<<"no input file!"<<endl; exit(1); } while(!infile.eof()) { cflight plane; infile>>plane.flnum>>plane.destination >>plane.amount>>plane.booking >>plane.departuretime>>plane.falltime; for(int i=0;i!=plane.booking;++i) { cpassenger tmp; infile>>tmp.name>>tmp.id>>tmp.seat; plane.list.push_back(tmp); } flight.push_back(plane); } infile.close(); } cflightsystem::~cflightsystem() { ofstream outfile("flight.txt"); if(!outfile) { cerr<<"no output file!"<<endl; exit(1); } for(vector<cflight>::iterator iter=flight.begin(); iter!=flight.end();++iter) { outfile<<iter->flnum<<' '<<iter->destination<<' ' <<iter->amount<<' '<<iter->booking<<' ' <<iter->departuretime<<' '<<iter->falltime<<' ' <<endl; for(vector<cpassenger>::iterator it=(iter->list).begin(); it!=(iter->list).end();++it) { outfile<<it->name<<' ' <<it->id<<' ' <<it->seat<<endl; } } outfile.close(); } int main() { cflightsystem management; return 0; }
when debug code , found console didn't return messege say, main function still called ? , don't know if destructor working hope..
i'm c++ freshman, , it's first time posting here... (sorry poor english..i hope can ..t.t)
Comments
Post a Comment