What about a linked list?
Or alternatively, you could store all the class instances in an array with as many elements as the the user inputs, and to check which instance has the student's ID run a loop through all the indexes.
An example to make it all clearer:
...
struct StudentInfo
{
...
unsigned int ID;
...
}
int main(void)
{
short int NumOfStudents;
cout<<"Input information on how many students?\n";
cin>>NumOfStudents;
StudentInfo Students[NumOfStudents];
short int Index;
for(Index=0;Index<NumOfStudents;Index++)
{
... // input students information
}
unsigned int ID_ToLookFor;
cout<<"Search for a student with what ID?\n";
cin>>ID_ToLookFor;
for(Index=0;Index<NumOfStudents;Index++)
{
if(Students[Index].ID==ID_ToLookFor) .. // do whatever you need to do here
}
...
}
Last edited by unbeatable0; Apr 14th, 2009 at 9:02 am.
Reputation Points: 42
Solved Threads: 13
Junior Poster in Training
Offline 90 posts
since Sep 2008