CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008
    Posts
    9

    Doubt, What its Meaning?

    Class CMyObject
    {
    public:
    CMyObject();
    ~CMyObject();
    };

    CMyObject *pMyObject;

    pMyObject = new CMyObject[10]; // What is its meaning


    Rajeev
    Thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Doubt, What its Meaning?

    An array of 10 CMyObject objects.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    May 2007
    Location
    Bangalore India
    Posts
    262

    Re: Doubt, What its Meaning?

    Quote Originally Posted by RajeevR
    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();
    Dont forget to rate my post if you find it useful.

  4. #4
    Join Date
    Jun 2008
    Posts
    9

    Re: Doubt, What its Meaning?

    Thank you very much.

  5. #5
    Join Date
    Aug 2007
    Posts
    135

    Re: Doubt, What its Meaning?

    it also means, when you are done using it, destroy it
    delete always goes hand in hand with new
    Code:
    delete[] pMyObject;
    Last edited by ChessMaster; June 18th, 2008 at 03:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured