Casting array of pointers to objects
- by ritmbo
If B is subclass of A.
And I have in main():
B** b = new B*[10];
... some algorithm that do b[i] = new B(..); ...
So I have an array of pointers to objets B.
Then I have a function:
void f(A** foo);
If in main, I do: f(b); I get a warning, but obviously if I do: f((A**)b);, i dont.
The (A**) its a bit nasty. I was wondering if there's a more elegant way in C++ that at least do type checking as dynamic_cast.