(scope?) question

  • Thread starter Bartholomew Simpson
  • Start date
B

Bartholomew Simpson

class DateTime
{
public:
typedef enum Format
{
DDMMYY = 0,
DDMMMYY ,
DDMMMYYYY ,
MMDDYY ,
IS08601
};

std::string ToString(const Format fmt= DateTime::ISO8601, const
std::string& sep="-" ) const ;
};


Error: error C2065: 'ISO8601' : undeclared identifier


Why can't the compiler recognizer the enum?

I tried typedefing the enum (although I read its not required in C++ -
same as struct declarations don't need a 'typedef' anymore)
 
S

Stefan Naewe

class DateTime
{
public:
typedef enum Format
{
DDMMYY = 0,
DDMMMYY ,
DDMMMYYYY ,
MMDDYY ,
IS08601
};

std::string ToString(const Format fmt= DateTime::ISO8601, const
std::string& sep="-" ) const ;
};


Error: error C2065: 'ISO8601' : undeclared identifier


Why can't the compiler recognizer the enum?

I tried typedefing the enum (although I read its not required in C++ -
same as struct declarations don't need a 'typedef' anymore)

0 != O (means 'Zero' != "Oh")

S.
 
J

James Kanze

class DateTime
{
public:
typedef enum Format
{
DDMMYY = 0,
DDMMMYY ,
DDMMMYYYY ,
MMDDYY ,
IS08601
};
std::string ToString(const Format fmt= DateTime::ISO8601, const
std::string& sep="-" ) const ;

Error: error C2065: 'ISO8601' : undeclared identifier
Why can't the compiler recognizer the enum?

Stefan already answered that (and I'll admit that I wouldn't
have seen it either).
I tried typedefing the enum (although I read its not required
in C++ - same as struct declarations don't need a 'typedef'
anymore)

The typedef'ing not only isn't necessary, it's somewhat harmful.
I'm not even sure it's legal in your case, since the typedef
doesn't apply to anything. Don't do it, except when writing
compatible headers, which must also be compiled by a C compiler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top