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!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.