3

I am getting a compile time for an enum in C++ , the error says Expected a class or namespace

  mf.setStatus(MediaFile::SyncStatus::Synced);

The enum is defined like this

 class MediaFile
 {
    public:
    enum SyncStatus 
    {
        New = 0,
        Remove = 5,
        Synced = 10,
        Unknown = 15
    };

    //...
 };

I am compiling in xcode but I guess it has to do with C++ syntax, previously it compiled fine on Visual studio. Visual studio probably gave some warnings about it, but did the build Any suggestions please ?

2
  • 1
    You're missing a semicolon at the end of your class declaration. Since you say this compiled under VS, this must simply be a typo in your question ;-) Commented Feb 1, 2013 at 22:48
  • yes, just a typo, actual class is a bit more complex :) Commented Feb 1, 2013 at 22:51

2 Answers 2

9

Try MediaFile::Synced instead. SyncStatus is a type name (as in SyncStatus theStatus), not a namespace.

Sign up to request clarification or add additional context in comments.

2 Comments

+1. Note that C++11 allows MediaFile::SyncStatus::... though.
Thanks, @Cameron, I had no idea.
4

enums in C++ do not define a namespace, so the values of the enumerator go into the surrounding context. You need to do MediaFile::Synced instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.