|
List Class cplusplus
|
|
01-23-2010, 06:28 AM
Post: #1
|
|||
|
|||
|
List Class cplusplus
List Class is pretty much the same in all programming languages. The only thing why people avoid using some classes is because of iterators. But you need to learn only basics and everything else will look so logical.
I am going to explain how to use list and i will give only integer examples, because all other types are pretty the same as integer. So first declaring list class on the top should look like this : Code: # include <list>Now let's show how to declare your list inside of the program : Code: list<type> name_of_the_list;Code: list<int> name_of_the_list (number_of_times, number_that_shows);For example list output would be : Code: 5 5 5Code: list<int> name_of_the_list (3,5);Code: empty Test whether container is empty Now let's show some examples. Let's read one list from the screen and write it's members backwards from user entering : Code: # include <iostream>Sort() function sorts list ascending. Now let's show that example : Code: # include <iostream>Code: # include <iostream>Hope you like it ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|





