Click to See Complete Forum and Search --> : Doubt, What its Meaning?
RajeevR
June 18th, 2008, 01:55 AM
Class CMyObject
{
public:
CMyObject();
~CMyObject();
};
CMyObject *pMyObject;
pMyObject = new CMyObject[10]; // What is its meaning
Rajeev
Thanks
cilu
June 18th, 2008, 01:58 AM
An array of 10 CMyObject objects.
code_carnage
June 18th, 2008, 02:00 AM
Class CMyObject
{
public:
CMyObject();
~CMyObject();
};
CMyObject *pMyObject;
pMyObject = new CMyObject[10]; // What is its meaning
Rajeev
Thanks
Well it means a dynamic array of size 10 of CmyObject class.
The object it holds are default initialized that means using default constructor.
pMyObject is the pointer to the first element of the array.
and follwing operation is perfectly fine..
pMyObject[4].CallMethod();
RajeevR
June 18th, 2008, 02:05 AM
Thank you very much.
ChessMaster
June 18th, 2008, 03:51 AM
it also means, when you are done using it, destroy it
delete always goes hand in hand with new
delete[] pMyObject;
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.