954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Homework Assignment Help/Question/Clairfication Plz

I am working with classes for the first time. I am trying to make an address book. While I think I have done my header files and class definition files correctly, I am running into a snag with getting it to show on the screen. I went back to a practice assignment I did that was somewhat similar. The only difference is, besides the obvious that is not an address book, is I didn't have to make it print on screen. I tried the following code:

void showStudents(ifstream& infile, studentType studentList[], int numberOfStudents)
{
	int count;

	for (count = 0; count < numberOfStudents; count++)
		cout << studentList[count].getFirstName << " " << studentList[count].getLastName << endl;
}


studentType is defined as

class studentType: public personType


This is the first question I have, does that mean studentType is the base class or persoType is the base class?

Anyways, as you can tell, I turned studentType into an array studentList[]. I am trying to get the first and last name of the students to print on a screen for a menu to choose from. the first name and last name is stored in class personType. When I try to compile the oroginal code I posted, void showStudents{.....},
I get an error code CS3867, and something about using pointers. If anyone can understand what I am trying to get at, please help the light bulp come on ;) Thanks.

Roebuc
Junior Poster
136 posts since Nov 2007
Reputation Points: 30
Solved Threads: 2
 

>>This is the first question I have, does that mean studentType is the base class or persoType is the base class?
personType is the base class.

>>cout << studentList[count].getFirstName
getFirstName is a function, so you need parentheses just like calling any other function
cout << studentList[count].getFirstName()

Same with getLastName -- use parentheses as above.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks for the help.

Roebuc
Junior Poster
136 posts since Nov 2007
Reputation Points: 30
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You