tmighty
tmighty

Reputation: 11399

C++: Function that returns an enum

I have declared the following enum in the header of my class:

class clsWString2
{


public:

    enum eTagType
    {
        TT_UNDEFINED,
        TT_RATEABSSPEED,
        TT_VOLUMELEVEL,
        TT_RATESPEED,
    };

Now I have created a private function in the cpp file:

eTagType clsWString2::wstringToTagType(wstring u)
{
     ...
}

This does not work. The compiler tells me "eTagType is undefined".

Can somebody help, please?

The following works:

void clsWString2::wstringToTagType(wstring u, eTagType &uRetValue)

... but I don't like this kind of function, I prefer having the function return a value, and I would also like to know what I am doing wrong.

Thank you for the help!

Upvotes: 0

Views: 99

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409186

The eTagType enumeration is in the scope of the clsWString2 class, so you have to tell the compiler it's scope:

clsWString2::eTagType clsWString2::wstringToTagType(wstring u) { ... }

Upvotes: 3

Related Questions