Passing a polymorphic array entry

I'm having an issue during the linking stage of the .exe during compile time, and it's because of a call to a function with a polymorphic parameter.
1
2
3
4
5
6
7
8
9
//here's how the classes are setup
class grandpa {};

class mom public grandpa{};
class dad public grandpa {};

class son public dad {};
class daughter public mom {};
//*Not actual code 


There's some arrays (which work perfectly fine)
1
2
std::vector< dad* > d;
std::vector< mom* > m;

dad has sons in the vector and mom has daughter in the vector. What I want to do is have a function that can accept either of these vectors as one parameter like so:
void func(const grandpa* aObject);

Finally, I have an error when I pass an object to the function like so:
func( d[0] );

Any suggestions?
Last edited on
A bit more stumbling around and I figured out it wasn't a polymorphic problem at all. I did that part right, I just forgot to scope the func into its class:

void doc::func(const grandpa* aObject);

Which explains the linking error. Whoops.
Last edited on
Topic archived. No new replies allowed.