Each array will hold objects. I have declared the student array and I have a constructor in the student class that doesn't take any arguments. So I have no problem declaring the objects.
The problem is, how do I define the objects and load them in the array?
Each student object contains the following data members. first name, last name, phone number (as string), GPA (as string) and # on hours enrolled (as int).
Using a for loop, how do I put these objects into the array?
And, oh yeah, it all needs to be written to an external file.
Here's my code so far:
Expand|Select|Wrap|Line Numbers
- #include "Student.h"
- #include <iostream>
- #include <string> //for string manipulation of names
- #include <iomanip> //for set width
- #include <fstream>
- ifstream FileinStu;
- void main()
- {
- //open external file
- // FileinStu.open("phoneBookStu.txt");
- //create 2 arrays to store data in and load from the file
- Student stuArray[10]; //ensure there is a constructor that accepts no arguements
- int stuCount = 0;
- for(int i = 0; i < 10 ; i++)
- // FileinStu>>stuArray[i];