Thread: C style arrays question

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    C style arrays question

    This is how to make a C style array of pointers right? Wondering cause I want to make an array that can be resized. Although I don't want to use STL. don't ask I'm weird.

    Code:
        int** T = new int*[1];
        T[0] = new int(100);
        std::cout << *T[0] << std::endl;
        delete T[0];
        delete [] T;
    Question is. Am I doing this right to avoid memory leaks? Wanting to know before I put it in a class, and stuff.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Am I doing this right to avoid memory leaks?
    Yes. So far. You'll have more work to do when you put in your class or when you try to actually resize it.

    >> don't ask I'm weird
    I won't ask, I'll just comment. It makes no sense to me.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Actually the main reason is because I want to try it myself. Not that I don't like the STL. Just seeing if I can do it myself. Self gratification basically.

  4. #4
    coder
    Join Date
    Feb 2008
    Posts
    127
    Doesn't seem that weird then

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about arrays.
    By Kelvie in forum C++ Programming
    Replies: 3
    Last Post: 09-17-2007, 05:32 AM
  2. A question about arrays
    By HAssan in forum C Programming
    Replies: 3
    Last Post: 11-08-2006, 03:09 AM
  3. Just a quick question about character arrays
    By Welshy in forum C Programming
    Replies: 3
    Last Post: 04-03-2006, 07:20 AM
  4. C++ Style Question
    By Davros in forum C++ Programming
    Replies: 7
    Last Post: 11-17-2004, 03:52 AM
  5. Question about arrays?? PLease read..
    By foofoo in forum C Programming
    Replies: 3
    Last Post: 06-24-2002, 02:40 PM