Thread: creating objects

  1. #1

    creating objects

    i am giving the option to create any no of class "Data" how can i do that since i will be asking him one by one not at once like i will not ask him to enter the number of objects to make. rather i will be asking like do you want another object to be created?

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Visalia, CA, USA
    Forgive me if I am totally misunderstanding. I think you want a vector.

    #include <vector>
    using std::vector;
    int main(void) {
      vector <my_object> array;
      // put code here
      return 0;

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    You should be more specefic, I cann't understand your question too.

  4. #4
    Registered User The Junglist's Avatar
    Join Date
    Nov 2002
    #define MAX_OBJECTS 200
    Object* MyObjects[MAX_OBJECTS];
    int i = 0;
    while( Answer == YES ) //Use an appropriate loop condition
         MyObjects[i++] = new Object;
    After the loop, i will be the number of objects that have been created.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Creating a map of objects with variable width and height
    By MrSparky in forum C++ Programming
    Replies: 6
    Last Post: 07-30-2007, 03:06 PM
  3. Creating vectors of objects!
    By bobthebullet990 in forum C++ Programming
    Replies: 17
    Last Post: 08-08-2006, 04:51 PM
  4. A question about dynamically creating an array of objects
    By edd1986 in forum C++ Programming
    Replies: 3
    Last Post: 03-19-2006, 12:30 PM
  5. creating objects in c++
    By sachitha in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2004, 12:19 PM