STL question

why write code that is in STL

Page 1 of 1

2 Replies - 511 Views - Last Post: 04 March 2009 - 12:38 PM Rate Topic: -----

#1 snowboarder6009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 11-September 08

STL question

Posted 04 March 2009 - 12:36 AM

Title might be a little hard to understand, sorry for that.

In my last programming class we had to write most of the functions for the different data structures like lists. My question is why is this of benefit when it is already done in the most efficient way in the STL? What do we gain from this?
Is This A Good Question/Topic? 0
  • +

Replies To: STL question

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: STL question

Posted 04 March 2009 - 12:58 AM

View Postsnowboarder6009, on 4 Mar, 2009 - 06:36 AM, said:

Title might be a little hard to understand, sorry for that.

In my last programming class we had to write most of the functions for the different data structures like lists. My question is why is this of benefit when it is already done in the most efficient way in the STL? What do we gain from this?

most of the programming tasks that students are given have already been done many times. Implementing data structures is useful in that students learn about allocating and deallocation memory, iterating thru the structures, etc, looking at different algorithms and comparing them for efficency. You also get an understanding of the pros and cons of different data structure and their areas of application.
Also one day you may have an application which requires a data structure that is not available. Also you may be working in C on embedded systems which do not have C++ and the STL and have to implement your own.
Was This Post Helpful? 0
  • +
  • -

#3 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: STL question

Posted 04 March 2009 - 12:38 PM

horace is spot on. Even though the STL programmers did a great job creating their data structures, it is still pretty common to see someone rewriting a linked list class or reimplementing the vector. Why? 1. The ultimate nerd excuse: 'cause i can! 2. because it requires a good amount of knowledge and helps one discover more information as they troll the web to find out why their class isn't working. I'll stop rambling now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1