T
Tommy Lang
I am working on this project and I need some help/pointers/comments to
get me started, I am stuck.
The program will be used to store information in an array while it is
running.
I need to store objects of my classes Person(superclass),
Student(inherit Person), Teacher(inherit Person) in that array.
The name will be the unique key. These classes are all working ok. I
want to be able to add, remove, find etc. objects.
To all of this, I have created a menue class to print out a menue on
the screen for the user where he can select what he wants to do(add,
remove...) and a class "List" to tie it all together.
In the menue class I have a reference(List &refList to the List
class and in the listclass I have a pointer to array that will hold
all the objcts(List *pList[10].
I init the reference in the constructor of Menu class like
menue::menue(const List &L):refList(L){}
Questions:
When I initiate the object List should I make sure to set all items in
array to NULL in the constructor ?
for(int i=0;i<10;i++)
pList=NULL;
Can I have only one array ex. List *pList[10]; that can hold all types
of objects(Person, Student, Teacher)?
Do I need typecasting to identify objects before adding removing..?
What methodes would I put in List class? (insert, remove, find, print)
When I am searching for an object in array, should I return the object
itself or a pointer to the object?
In case of returning a pointer, how do I return a pointer to the
object I am searching for?
Thankful for any help
/Tommy
get me started, I am stuck.
The program will be used to store information in an array while it is
running.
I need to store objects of my classes Person(superclass),
Student(inherit Person), Teacher(inherit Person) in that array.
The name will be the unique key. These classes are all working ok. I
want to be able to add, remove, find etc. objects.
To all of this, I have created a menue class to print out a menue on
the screen for the user where he can select what he wants to do(add,
remove...) and a class "List" to tie it all together.
In the menue class I have a reference(List &refList to the List
class and in the listclass I have a pointer to array that will hold
all the objcts(List *pList[10].
I init the reference in the constructor of Menu class like
menue::menue(const List &L):refList(L){}
Questions:
When I initiate the object List should I make sure to set all items in
array to NULL in the constructor ?
for(int i=0;i<10;i++)
pList=NULL;
Can I have only one array ex. List *pList[10]; that can hold all types
of objects(Person, Student, Teacher)?
Do I need typecasting to identify objects before adding removing..?
What methodes would I put in List class? (insert, remove, find, print)
When I am searching for an object in array, should I return the object
itself or a pointer to the object?
In case of returning a pointer, how do I return a pointer to the
object I am searching for?
Thankful for any help
/Tommy