declaring an array of CPoints

This is a discussion on declaring an array of CPoints within the C++ Programming forums, part of the General Programming Boards category; I'm using VC++ 6 and need to declare an array of CPoints but don't know how many points will be ...

  1. #1
    swordfish
    Guest

    declaring an array of CPoints

    I'm using VC++ 6 and need to declare an array of CPoints but don't know how many points will be in the array. Do you know how to declare an array of CPoints without specifying the the maximum number of CPoints that will be in the array?

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You'll either have to use something like a vector or dynamically create the array using new (and delete).

    ........
    int cpoints;
    CPoint* pCPoint;

    cout << "enter points: ";
    cin >> cpoints;
    pCPoint = new CPont[cpoints]; //CPoint needs default constructor
    //Do stuff
    delete [] pCPoint;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 11-06-2005, 08:29 PM
  2. Error with an array
    By SWAT_LtLen in forum C++ Programming
    Replies: 2
    Last Post: 03-29-2005, 10:00 AM
  3. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. help with declaring array in which the user specifies size
    By ibanezrgking in forum C++ Programming
    Replies: 3
    Last Post: 02-10-2002, 09:05 AM

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