Say I have some structs like this:
struct A{
int someInt;
}
struct B : public A{
int someInt;
int someOtherInt;
}
And a class:
class C{
A *someAs;
void myFunc(A *someMoreAs){
delete [] someMoreAs;
}
}
would this cause a problem:
B *b=new B[10];
C c;
c.myFunc(b);
Because it's deleting b, thinking that it's of type A, which is smaller. Would this cause a memory leak?
Also, say I want to allocate more of the same as b within myFunc, using new, but without C knowing whether b is of A or B? A friend sugegsted typeof, but VC doesn't seem to support this.