I have a snippet of code here, of which I don't understand why it results in a segmentation fault on line 22 (delete[] statement). Can you please explain this to me?
#include<iostream>
#include<memory>
class A {
  size_t a[1000];
  public:
    virtual ~A() { }
};
class B : public A {
  public:
    float b;
    virtual ~B() { }
};
int main(int argc, char** argv){
  A *b;
  b = new B[10];
  delete[] b;
  return 0;
}
Strangely, if class B doesn't have any member variables (i.e. I comment out the line "float b;") then the code just runs fine.
What's my mistake here?
 
     
     
     
    