polymorphism and pointer arrays

i cant do this?

1
2
3
4
5
6
Domestic *bucketPets = new Puppy;
int menuarray[4] = {new Puppy};


//i want to make a menu for my 4 classes all inherited
//dog cat kitten puppy 
i cant do this?

No.


1
2
//i want to make a menu for my 4 classes all inherited
//dog cat kitten puppy  

I see no evidence of a menu class. All I see is an array of int.
Last edited on
wait i need to make a menu class?
wait i need to make a menu class?

I'm afraid I misread the original post. However, you obviously cannot store pointers in an array-of-ints.
Domestic* menuarray[4] = {new Puppy};
i want to make a menu now
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//my beginning of my pointer to array menu
Domestic* menuarray[4] = {new Puppy(age,birthday), new Kitten(age), new Dog(age), new Cat(age)};




//function for menu

int menu(int operation)
{
	cout << "1. Puppy" << endl;
	cout << "2. Kitten" << endl;
	cout << "3. Dog" << endl;
	cout << "4. Cat" << endl;
	cin >> operation;
	
	return operation;
}







Last edited on
Topic archived. No new replies allowed.