0

Suppose I have a class like this:

class MyClass : private vector<AnotherClass*> {
//some codes
}

How do I implement its destructor? I am new to C++ and have totally no clue on this.

Thanks in advance!

edit: fixed the syntax,thx for remaindering me!

Fermat's Little Student
  • 5,549
  • 7
  • 49
  • 70

1 Answers1

3

Don't derive from std::vector. Better use std::vector and a smart pointer class like shared_ptr or unique_ptr (also see here).

And a warning: don't use std::auto_ptr in containers because it will not work as expected in most circumstances.

Community
  • 1
  • 1
Axel
  • 13,939
  • 5
  • 50
  • 79