My C++ Quiz

The ultimate place to learn C++!

Question #27: Which lines of code below should cause the program to be undefined?

 1 struct Foo
 2 {
 3   virtual ~Foo() {}
 4 };
 5
 6 struct Bar : public Foo
 7 {
 8 };
 9
10 int main(int argc, char** argv)
11 {
12   Foo* f = new Bar;
13   delete f;
14   f = 0;
15   delete f;
16
17   Foo* fa = new Bar[10];
18   delete [] fa;
19   fa = 0;
20   delete fa;
21
22   return 0;
23 }