October 13th, 2002, 11:37 AM
Implemenation of <vector> class function, PushBack()
For any of you that is familar with the <vector> class, I need to ask you a huge favor. For my HW, I need to write a 'cheap imitation' version of the vector class except my version is going to be called TVector. It's protected data member include size and capacity and also a method name newarray() that acts as a safe space allocator. This imitation vector class like the real one, is a generic template.
My assignment is to implement my version of the PushBack() method for the vector class(without using any other classes).
The prototype will look like so:
Can anyone with an in-depth knowledge of STL help me with this?
int PushBack(const T&);
//We increase size by one and insert a copy of the parameter value into newly allocated vector element.
//What if size cannot be increased without increasing capacity
October 13th, 2002, 03:21 PM
Simply derive your class from the std::vector, and overload the operations that you want to change the behaviour of?