I have a class called "poly". I want to dynamically create an array of pointers to poly objects. The variable "totalPolynomials" holds the number of poly objects.
Here is my code to declare the array:
poly **polyPtr;
polyPtr = new poly *[totalPolynomials];
I successfully create poly objects, but don't know how to store their pointers in the array one after another...
If you are creating them and then want to store them, you can do something like
poly ** polyPtr;
polyPtr = new poly* [totalPolynomials];
for(int i = 0; i<totalPolynomials; ++i)
{
polyPtr[i] = new poly(arguments);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With