#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Tallahassee
    Posts
    55
    Rep Power
    14

    Question Implemenation of <vector> class function, PushBack()


    Hey all,
    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:
    Code:
    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
    Can anyone with an in-depth knowledge of STL help me with this?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    London
    Posts
    349
    Rep Power
    13
    Simply derive your class from the std::vector, and overload the operations that you want to change the behaviour of?

IMN logo majestic logo threadwatch logo seochat tools logo