473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inheritance of the vector class

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.
Define:

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;
  5.  
  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. };
  13.  
  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
0 2494

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

Similar topics

4
by: Dave Theese | last post by:
Hello all, The example below demonstrates proper conformance to the C++ standard. However, I'm having a hard time getting my brain around which language rules make this proper... The error...
19
by: Mike Tyka | last post by:
Hello community, i'm fairly new to using the STL but i've been experimenting a bit with it. I tried to derive a new class say MyString from string like so: class MyString: public string{...
2
by: Søren Holstebroe | last post by:
Hi there, I'm having a struggle with GNU g++ (3.3.5) and inheritance of typedefs in STL containers. I'm trying to port some old code I wrote with MS Visual C++ and it looks like there is a...
8
by: Ben Pope | last post by:
Hi everybody, I know this is not usually the place for design questions, but I was wondering what some of you more experienced people would do. Say I have an application that has a C++ & STL...
3
by: Tony Johansson | last post by:
Hello experts! I have a small program that is using multiple inheritance. There are 4 classes involved I get 4 compile error that I can't figure out why. It's this row which is located in the...
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
2
by: shuisheng | last post by:
Dear All, I have a question on inheritance. Assume I have a base class Vector and its derived class DecoratedVector as follows: class Vector { // Constructors. Vector(); Vector(size_t num,...
1
by: Michael Hines | last post by:
Hello, I have a class factory that supports single inheritance but it is an error if the base appears twice. e.g class Foo(hclass(h.Vector), hclass(h.List)): should raise an exception since...
2
by: Paul McGuire | last post by:
On May 25, 8:37 am, Michael Hines <michael.hi...@yale.eduwrote: Here's a more general version of your testing code, to detect *any* diamond multiple inheritance (using your sample classes). --...
2
by: hanna88 | last post by:
hello... i am looking for a better way of doing Class Matrix. the current code i have now is Class Vector which is inherited from Class Base. Class Matrix needs the vector in Class Vector and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.