Mark
Mark

Reputation: 6484

fail to use type in public method

namespace iris {
    namespace imon {
        class myclass {
            private:
                typedef enum ppTag {
                    X1 = 0,
                    X2 = 1,
                    X3 = 254,
                    X4 = 255
                } pp;

                typedef struct {
                    int x;
                    int y;
                    int z;
                } Data;
                pp myFunc();

            public:
                myclass() { };
                virtual ~myclass() {};
                int func();
        };

        pp myclass::myFunc()
        {
         ...
        }

        int myclass::func()
        {
            return 0;
        }
    }
}

g++ returns error: pp does not name a type

I thought I can easily use privately declared structures, typedefs etc. within public methods of the class. What else am I doing wrong?

Upvotes: 0

Views: 35

Answers (1)

Timo Geusch
Timo Geusch

Reputation: 24351

You need to qualify the type in order to access it:

    myclass::pp myclass::myFunc()
    {
     ...
    }

Upvotes: 2

Related Questions