You can also create a race of objects in dynamic memory using the new operator.
So you did this by providing the number of items you want to create in a pair of square braces here.
So this code here, that driver light here P new integer two and P zero.
Zero here one and this pointer here.
P plus one.
And here, two.
And then we're going to create a for loop here integer E zero.
While E less than.
Two.
Increment E by one.
And then we're going to print the print the P variable here, P here.
In line.
And after this for loop, we're going to delete the P.
Yeah.
So the operator here returns a pointer to the time allocated.
So and you use the pointer arithmetic or array indexing to access the memory.
You cannot initialize the memory in the new statement, so you have to do that after creating the buffer
here.
So when you use a new to create a buffer for more than one object, you must use the appropriate version
of the delete operator.
And the caller braces is used to indicate that the more than one item is deleted and the destructor
for each object will be called.
So it's it's important that you always use the right version of delete appropriate to the version of
new here used to create the pointers here.
So custom types can define their own operator, the new operator and the late operator for individual
objects.
So as well as the operator, new collaborators here and operator.
The delete caller is here for array of objects here, so the custom type order can use these to use
custom memory allocation schemes for their objects.
And here, if we get the failed.
When you're doing this, if the new operator cannot allocate the memory and for an object, it will
throw the STD std bad.
I look about all the exception and the point pointer return will have the new TR here, so exceptions
are covered in next lecture, next lectures.
So.