Hi There,
I have a class called person...
class person //define person class
{
int currentfloor;
int destfloor;
char name [10];
public:
//Come in creates 20 people instances
void come_in(void);
void exit(int num);
person::person()
{
static int count = 0;
const int recordlength = 16;
//load a person from person.txt and store them
ifstream infile;
infile.open("person.txt");
if(!infile.fail())
{
cout << "initialising person " << count+1 << "..." << endl;
infile.seekg(recordlength*count++, ios::beg);
infile >> name >> currentfloor >> destfloor;
infile.close();
}
else
{
cout << "File not found..." << endl;
cout << "Fatal error..." << endl;
cout << "Terminating program..." << endl;
//How can I terminate the program from here??
}
}
};
My question is how can I terminate my program when there is an error in person::person? i have tried to pass a number through person::exit
which changes elevator1.closed (elevator is another class in my program) however, the compiler says that it's an undeclared idetifier.
I've included my source in a zip file to show u what i mean in more detail.
Any help would greatly be appreciated!
Thanks
Regards,
Smithy.
