what is wrong with that?

Sharky Forums


Results 1 to 4 of 4

Thread: what is wrong with that?

  1. #1
    Goldfish
    Join Date
    Sep 2006
    Posts
    65

    Post what is wrong with that?

    const int NUM_ROW=15;
    const int NUM_COL=15;
    typedef int [NUM_ROW][NUM_COL] TwoDimArray;
    can someone tell me how to correct that?
    I'm so confused that this is giving me errors and warnings, i use visual C++ 6.0.
    i looked at my notes it seems that there is something wrong
    please help

  2. #2
    Hammerhead Shark
    Join Date
    Feb 2001
    Posts
    1,612
    You may have to change your file extension from .c to .cpp. If that doesn't work, change 'const int NUM_ROW=15;' to '#define NUM_ROW 15'. I know C++ doesn't like using variables in array declarations, and I'm not sure if they ever made 'const' act like an actual constant, rather than just a variable that you can't change.

  3. #3
    Goldfish
    Join Date
    Sep 2006
    Posts
    65
    Not working Strogian, can someone please write me how to create a new type TwoDimArray of size NUM_ROW NUM_COL using typedef?
    crap i have a project!

  4. #4
    Hammerhead Shark
    Join Date
    Feb 2001
    Posts
    1,612
    Oh whoops, didn't realize it was a typedef. You need to put the indexers after the identifier. Basically, the rule is, take away the word 'typedef', and you should have a valid declaration:

    typedef int TwoDimArray[NUM_ROW][NUM_COL];
    int xyzArray[NUM_ROW][NUM_COL];

Posting Permissions

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