The problem was
"create an array of at leat four pointers to Reader object. Use the New operator to create at leat four pointers to derived class objects and assign them to the array"
The reader is the base class. The fantasyReader, horrorReader, misteryReader, and scienceReader are derived class.
I have to read from Reader.txt
"""""""""""contents""""""""""""
David
0 <-Mystery category
John
1 <-Horror category
Mark
2 <-Science category
Sarah
3 <-fantasyReader
"""""""""""""""end"""""""""""""""""""
What I have
enum {HORROR, MYSTERY, SICENCE, FANTASY};
int main(void)
{
Reader *obj[10];
ifstream reader_file;
int category =0;
string name;
string number;
int counter = 0;
if(reader_file.is_open())
{
while( getline(reader_file, name, '\n') &&
getline(reader_file, number, '\n'))
{
switch(category)
{
case FANTASY:
obj[counter++] = new fantasyReader(name);
break;
case MYSTERY:
obj[counter++] = new mysteryReader(name);
break
case HORROR:
obj[counter++] = new horrorReader(name);
break;
case SCIENCE:
obj[counter++] = new scienceReader(name);
break;
}
}
}
}
Im not sure if my codes are answering the question above.
{}button.;in your code (aftercounter = 0).