Results 1 to 10 of 10

Thread: class problems!!

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    East Ballina,NSW,Australia
    Posts
    121

    Exclamation class problems!!

    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:erson()
    {
    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:erson? 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.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width