Lab 10 - Classes

Copy class_example.cpp to your Helios account using the command:
cp /usr/users/mdanfor/public_html/cs221-f06/class_example.cpp .
Compile and run the example. This is the class version of the structure from Lab 9. There are two functions for input, one for keyboard input and one for file input. The keyboard input function has been done already.

Lab Assignment

Write the new_from_file() function for the class and modify the get_input() program function to ask for a filename, open the file and call new_from_file() to read in the student information. After calling new_from_file, check that the file still has data before the next loop iteration. Use the same input files as last week: These files are in what is called a tab seperated format. There is a tab between the name and student ID. There is a second tab between the ID and phone number. There is a space between the first name and last name. Your get_input function should use this code to open the file:
ifstream fin;
char filename[30];

printf("Enter filename: ");
cin >> filename;
fin.open(filename);