C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2002, 10:37 AM
supaben34 supaben34 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Tallahassee
Posts: 55 supaben34 User rank is Corporal (100 - 500 Reputation Level)supaben34 User rank is Corporal (100 - 500 Reputation Level)supaben34 User rank is Corporal (100 - 500 Reputation Level)supaben34 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 57 m 51 sec
Reputation Power: 12
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?

Reply With Quote
  #2  
Old October 13th, 2002, 02:21 PM
rendy's Avatar
rendy rendy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: London
Posts: 349 rendy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 19 m 21 sec
Reputation Power: 11
Simply derive your class from the std::vector, and overload the operations that you want to change the behaviour of?
__________________
Invoice Software

here

click here

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Implemenation of <vector> class function, PushBack()

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap