Help!! compilation error for initilizing static set data member

This is a discussion on Help!! compilation error for initilizing static set data member within the C++ Programming forums, part of the General Programming Boards category; I could not compile the following code in window VC++. There are some syntax errors like: syntax error : missing ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Help!! compilation error for initilizing static set data member

    I could not compile the following code in window VC++. There are some syntax errors like:
    syntax error : missing ';' before '<' on line 17,

    However on UNIX, I think I can compile line 17, but I still have compilation problem for static set definition or initilization , the error is:
    Could not find a match for operator new(unsigned, const aclass::MKey*).

    Does it make sense to you guys? Appreciate it if anyone could give any hint?

    //=================================
    // aclass.h
    //=================================
    #include <set>

    class aclass
    {
    public:
    struct MKey
    {
    int length;
    int height;
    bool operator <( const MKey &) const;
    };

    typedef aclass *ptr;
    typedef set<const MKey, less <const MKey> > TABLESET;

    static TABLESET s_tableset;

    private:
    };

    //=================================
    // aclass.cc
    //=================================
    aclass::TABLESET aclass::s_tableset;

    bool
    aclass::MKey:perator< (const MKey &key ) const
    {
    if ( length == key.length )
    {
    return ( height < key.height );
    }
    return length < key.length;
    }

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    >There are some syntax errors like:
    >syntax error : missing ';' before '<' on line 17,


    That first error simply means you forgot to put a semicolon after a line of code, or it could also mean that your syntax of code was wrong...look through the code and find it.
    My Website

    "Circular logic is good because it is."

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    I don't know. I don't think it is any syntax error here. Or it is not the reason for compilation failure. I doubt if I need to overload operator new function in Mkey struct. Can anyone verify this?
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  3. Declaration/Definition ??
    By Manish in forum C++ Programming
    Replies: 4
    Last Post: 03-03-2002, 10:37 AM
  4. Static member data inaccessible
    By BSTRhino in forum C++ Programming
    Replies: 2
    Last Post: 01-10-2002, 08:28 PM
  5. How do I base size of arrays on annother number?
    By Dual-Catfish in forum C++ Programming
    Replies: 15
    Last Post: 09-25-2001, 01:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21