Thread: declaring an array of CPoints

  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
    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, 09:29 PM
  2. Error with an array
    By SWAT_LtLen in forum C++ Programming
    Replies: 2
    Last Post: 03-29-2005, 11: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, 10:05 AM