By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Inheritance of the vector class

P: 3
I was running through a data structures book and I was curious if anyone could inform me of how to inherit the vector class to do a simple search and erase function. The example states:

vector_plus is a subclass of the vector class.
vector_plus has no new fields.

void erase_item(const T& item);

Here is an example of my header file:

Expand|Select|Wrap|Line Numbers
  1. #ifndef VECTOR_PLUS
  2. #define VECTOR_PLUS
  3. #include <vector>
  4. using namespace std;
  6. template<class T>
  7. class vector_plus : public vector<T>
  8. {
  9.   public:
  10.     vector_plus();
  11.     void erase_item(const T& item);
  12. };
  14. #endif
In the erase_item method I would use the find method defined in <algorithm> and the erase method in <vector>. I have tried to figure this out for a few days now and keep getting errors within the declaration of the erase_item method.

Thank you so much for your help.
Apr 15 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.