size of dynamic memory

How do I get the number of elements from a pointer like this:
MyClass *mc = new (nothrow) MyClass[size];
In my own code the 'size' variable depends on user input, but I don't know how to how to retrieve the number of elements of 'mc'. Or is there no other way than save the number of elements (in this case 'size') when I allocate the memory to mc?
There is no way to retrieve the number of elements from mc. You have remember it separetly in another variable.
ok thanks
For this reason standard library provides std::vector: http://www.cplusplus.com/reference/stl/vector/
It's like a dynamically allocated array but it's much easier to use
Topic archived. No new replies allowed.