creating objects

This is a discussion on creating objects within the C++ Programming forums, part of the General Programming Boards category; i am giving the option to create any no of class "Data" objects.so how can i do that since i ...

  1. #1
    Bilo
    Guest

    creating objects

    i am giving the option to create any no of class "Data" objects.so 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
    Location
    Visalia, CA, USA
    Posts
    3,685
    Forgive me if I am totally misunderstanding. I think you want a vector.

    Example
    Code:
    #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
    Posts
    953
    You should be more specefic, I cann't understand your question too.
    none...

  4. #4
    Registered User The Junglist's Avatar
    Join Date
    Nov 2002
    Posts
    42
    Code:
    #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, 11:30 AM
  5. creating objects in c++
    By sachitha in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2004, 12:19 PM

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