Thread: dynamic two dimensional arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    100

    dynamic two dimensional arrays

    I can successful declare a dynamic one dimensional array (size is unknown at compilation) but I can't get my program to compile when I try to make it two dimensional. Here is what worked:

    header.h
    Code:
    [snip]
    int *myLocations;
    main.cpp
    Code:
    [snip]
    routeData myRoute;
    myRoute.myLocations = new int[10];
    Here is what didn't work:

    header.h
    Code:
    int *myLocations(*);
    main.coo
    Code:
    routeData myRoute;
    myRoute.myLocations = new int[10][10];
    The 10s are just examples of what may come from what the user specified the array size to be.

    Or would it be best to just use a two dimensional vector, since those don't seem to need to have size constraints on them?
    Last edited by Beowolf; 10-30-2007 at 04:13 PM.
    "I don't fail - I succeed at finding things that don't work"
    Website Promotion Techniques @AbstractPromotion.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating and freeing dynamic arrays
    By circuitbreaker in forum C++ Programming
    Replies: 8
    Last Post: 02-18-2008, 11:18 AM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  4. processing dynamic arrays
    By Mario F. in forum C++ Programming
    Replies: 9
    Last Post: 06-04-2006, 11:32 AM
  5. Dynamic (Numeric) Arrays
    By DavidB in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2006, 07:34 PM