I have a class that says four integers I need to create 1 million examples of the above class. How do I create. .?
The ethical approach is: class arrMyObjectes [1000000];
But it will be 1million * sizeof (obj) = 16 million bytes of continuous memory block ****, which will be difficult to meet ..
< P> The better way would be: * Class arrMyObjectes [1000000];We will now create 100,000,000 objects using new and we will store points in the above indicator array ... even here In this case we need 1 million * size (indicator) = 4million bytes of continuous memory block .. It is also difficult to think ..
Is there any other Better way
about std :: deque & lt; Class & gt; Objects (1000000);
or std :: list & lt; Classes & gt; Objects (1000000);
. None of those containers are compatible.
If the implementation tries to catch the closest block for those constructors, you can generate them individually:
std :: deque & lt; Class & gt; Objects; For (unsigned i = 0; i <1000000; ++ i) objects .emplace_back ();
Similar to std :: list
Reference:
No comments:
Post a Comment