Thread: Is this not legal syntax?

  1. #1
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802

    Is this not legal syntax?

    unsigned int m_iPageNames[] = {IDD_COLORS, IDD_KEYWORDS, IDD_OPERATORS};

    This is declared protected in my CDialog class...
    I mean, my god, I practically copied the example from MSDN and I get 6 errors for that line?

    color coderdlg.h(34) : error C2059: syntax error : '{'
    color coderdlg.h(34) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    color coderdlg.h(34) : error C2059: syntax error : '{'
    color coderdlg.h(34) : error C2334: unexpected token(s) Color CoderDlg.cpp(121) : error C2065: 'm_iPageNames' : undeclared identifier
    Color CoderDlg.cpp(121) : error C2109: subscript requires array or pointer type

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Just a quick, and even stupid question, are IDD_COLORS and etc. defined before this array definition?

  3. #3
    Unregistered
    Guest
    Looks good to me

  4. #4
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Yes

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    317
    OK, so are they variables or constants? If variables you might want to try dynamically allocating the array using new.

  6. #6
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Nope... they're constants :/
    I cannot understand this... it's so frustrating. If the compiler was a person, I'd punch it in the face and tell it i'm right... but since it's not, I have no way of doing this :/

  7. #7
    I actually had the same problem. But I was able to hunt down one of the programmers that made the C++ compiler and punch him in the face. But I still don't know how to fix it and now I have an assault lawsuit.
    -Mike
    {InFeStEd-ArCh0n}

  8. #8
    Registered User
    Join Date
    May 2002
    Posts
    317
    Just curious, how and where are they defined(that is IDD_COLORS ect..); of course assuming you'll indulge me.

  9. #9
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    look above this line for errors! the error is likely there.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  10. #10
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    no-one is prolly right. You have an error which messes up the rest of the code.
    Maybe an extra { somewhere.

  11. #11
    No, I'm pretty sure that's the way you're supposed to do it. Wait... try delcaring it as a constant. Maybe that will work?
    -Mike
    {InFeStEd-ArCh0n}

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And if all else fails:

    unsigned int m_iPageNames[3] = {IDD_COLORS, IDD_KEYWORDS, IDD_OPERATORS};


    Also, did you comment out the "protected:" keyword to see if it still compiles?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    Registered User
    Join Date
    May 2002
    Posts
    317
    Alright, so are IDD_COLORS (ect) defined as static variables? If not your getting an error because you cannot initialize an array like that within the class definition, because the class is merely describing the data, until an object is initialized you don't actually have anywhere to put the data. So you could use static variables or if that doesn't work try moving the initialization to the constructor definition of your class. (Mind you this is just how I read it, I could be totally off the wall here).

    Edit:

    By the way you can also use an enumeration as opposed to declaring the variables static.
    Last edited by Traveller; 05-05-2002 at 08:15 AM.

  14. #14
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Ahhh, I tried everything.. moving them to public, making them constant etc etc.

    Enumeration sounds like a good plan.

  15. #15
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Correction, enumeration SOUNDED like a good plan...
    Same errors

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM