indefinite number of datapoints question

This is a discussion on indefinite number of datapoints question within the C++ Programming forums, part of the General Programming Boards category; Code: struct intArray(int size) { switch (size) { case 1: { int a0; break; } case 2: { int a0, ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    44

    indefinite number of datapoints question

    Code:
    struct intArray(int size)
    {
        switch (size)
        {
            case 1: { int a0; break; }
            case 2: { int a0, a1; break;}
            case 3: { int a0, a1, a2; break; }
        }
    };
    Is there a way to keep specifying member variables in this fashion without specifying a definite number of possible variables?

    For example, when size is 250 I want 250 variables (a0 - a249).

    I realize this looks like a simple array of integers, but for my purposes an array won't work.
    Check out all my dimensions:
    Height, width, and for a limited time only... Depth!
    -sb

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    look up vector. It's an STL template class that stores a variable number of any type.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-20-2009, 11:37 PM
  2. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  3. help with number menu
    By j4k50n in forum C Programming
    Replies: 12
    Last Post: 04-17-2007, 01:33 AM
  4. Question about limiting the number of user inputs in C
    By chobibo in forum C Programming
    Replies: 15
    Last Post: 08-30-2006, 12:37 AM
  5. Question about the wierd number representations
    By Jaken Veina in forum C Programming
    Replies: 13
    Last Post: 04-07-2005, 11:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21