class game_list
{
public:
string name;
float price;
string platform;
string console;
string condition;
bool is_portable;
string N_bits;
};
class catridge_object:public game_list
{
string N_bits;
bool is_import;
};
class disk_object:public game_list
{
string disk_type;
int n_disk;
};
class digital_object:public game_list
{
float file_size;
bool is_for_pc;
};
game_list *pointerMain;
int main()
{
int optionChosen=0;
vector<game_list*> mainVector;
}
here game_list
is the parent class and there are child classes derived from it. I am trying to create a list of game_class
objects that the vector mainVector
will hold. Now, depending on user input, all the objects inside the vector will have the common attributes that are described in game_list
class and also depending on what user chooses, it will have an additional info from the 3 other child classes derived from the parent class. So I will be creating a dynamic
game_list
using the following command
pointerMain=new game_list;
Everything seems ok but the problem is when I try to access the child class using pointerMain->(any member of the child class)
, it doesnt work that way. Any ideas on what to do?