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;
}