|
| kenr (7) | |
void SomeFunc(ClassA **inst) { ... } Class ClassA { ... } Class ClassB: public ClassA { ... } main { ClassA *instA = new ClassB(); SomeFunc(&instA); // this compiles and works fine ClassB *instB = new ClassB(); SomeFunc(&instB); // but this will not compile } I tried a static cast but still could not get to compile here is what the complier is grippin about: cannot convert `ClassB*' to `ClassA**' for argument | |
| helios (6074) | |
SomeFunc((ClassA **)&instB); should work.Why do you need to pass a pointer to a pointer? Are you going to modify where the pointer points to? | |
| kenr (7) | |
| Are you going to modify where the pointer points to? No. This was more of an exercise in pointer/address gymnastics which I need lots of practice in. | |
| Abramus (81) | |
| Implict conversion from ClassB** to ClassA** is inhibited because it is dangerous. Please read this: http://www.parashift.com/c++-faq-lite/proper-inheritance.html#faq-21.2 | |
This topic is archived - New replies not allowed.
