Results 1 to 1 of 1

Thread: Understanding memory allocation

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    198

    Understanding memory allocation

    I'm new to c++ but I do have a programming background.
    I understand that there are three ways of allocating memory: on the stack statically, on the stack dynamically and on the heap dynamically. I just don't understand which one will take place with the following statements and how to delete memory used by them:

    Code:
    class MyClass1
    {
          int intArray[10];
          ...
    }
    
    class MyClass2
    {
          int* intArray;
          ...
    }
    
    class MyClass3
    {
          OtherClass anotherObject;
          ...
    }
    
    class MyClass4
    {
          OtherClass* anotherObject;
          ...
          public:
              void TestMethod();
    }
    
    void MyClass4::TestMethod()
    {
         OtherClass* localObject = new OtherClass;
    }
    Thanks in advance.
    Cheers.
    Last edited by mariano_donati; Aug 16th, 2010 at 04:28 PM. Reason: Adding more statements

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