Thread: What does this line of code mean?

  1. #1
    Registered User
    Join Date
    Jul 2005

    What does this line of code mean?


    I'm very much a C++ newbie and I'm trying to read some code I've been given, but I can't find what this line means:

    list< int > result;
    'result' seems to be a class of some sort, but I don't understand this syntax at all. Does anyone have any ideas?

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    you may want to take a look into the C++ Standard Template Library or STL for short
    Join is in our Unofficial Cprog IRC channel
    Channel: #Tech

    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    list is a template class, which means you can have lists of whatever you want.
    In this case, it's a list of ints.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Apr 2003
    The C++ language has certain features like variables and arrays. An array can be used to store more than one value. C++ also provides you with other "containers" that can store more than one value. One of those "containers" is called a list. The code:
    list< int > result;
    declares a list named "result" that will contain ints. It uses a different syntax, but it is similar to how you would declare an integer array:
    int myArray[10];
    However, with a list, you don't have to specify the size. The size of the list changes automatically as you add ints to it.
    Last edited by 7stud; 07-28-2005 at 01:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C code line, pointer declaration
    By Dedalus in forum C Programming
    Replies: 2
    Last Post: 06-10-2009, 04:34 AM
  2. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 12:48 PM
  3. Can't figure out a line of code...
    By bamera in forum C++ Programming
    Replies: 1
    Last Post: 10-15-2005, 07:11 PM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM