0

I have a very basic question.

.h

private:
list <int> Stack;

typedef enum
{
    Push,
    Pop,
    Min,
    Display
}Operation;

Operation map(string s);

.Cpp:

Operation min_Stack::map(string s)
{

The compiler is not complaining for .h file but for .cpp its giving error : "identifier operation is unidentified".

I am unable to find what I did wrong here.

3
  • 1
    The problem is unrelated to the typedef. The enum is declared in the scope of min_stack. Commented Feb 8, 2014 at 15:08
  • Don't do typedef enum (or struct, or class) {} X;, it's a Cism. Just write enum X {};. Commented Feb 8, 2014 at 15:11
  • In C++, the typedef is not required. Commented Feb 8, 2014 at 19:27

1 Answer 1

4

Instead of

Operation min_Stack::map(string s)

write

min_Stack::Operation min_Stack::map(string s)

The compiler searches the return type in the namespace scope and it did not find the name because the name is defined inside class min_Stack.

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

1 Comment

wow.. how silly of me.. will accept this answer as soon as the site allows me :)

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.