My C++ Quiz

The ultimate place for testing what you have learned



Home | Start Quiz | List of questions  | Next Question | Login / Register

Question #27: Which lines of code below should cause the program to be undefined?
45% on 2228 times asked

 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 }

none
13
15
18
20
© 2007-2010, My C++ Quiz, All rights reserved.
Can you find a bug in the quiz? Can you think of a new question that would be cool to add to this site? Email us and we will take action:
email us
Other Quizes | Contributors