I want to do what's said in the title but I run in the following error:
error: invalid conversion from ‘Child**’ to ‘Parent**’ [-fpermissive]
For clarity, here is my parent.hpp file:
#ifndef PARENT
#define PARENT
class Parent
{
//something
};
#endif
Here my child.hpp file
#ifndef CHILD
#define CHILD
#include "parent.hpp"
class Child : public Parent
{
//something
};
#endif
And here is the function I'm trying to use:
void func(Parent *p[])
{
//something
}
int main()
{
Child *c[10];
func(c);
}
I would like to know why this happens while it does not when the parameter is a simple pointer, and how I could get it to work without using templates, provided such a way of solving the problem exists.