Issue with Enum usage

Viewed 369

I have an issue with Enum (and I guess its usage): I've declared an Enum in a class and I'm trying to use it in its subclass. Here the (abstract) superclass:

//Function.h
class Function {
public:
    enum FunctionType {
        constant,
        variable,
        sum,
        mul
    };
    ...
    virtual FunctionType getType();
};

here one of its subclass:

//Const.h
#include "Function.h"

#ifndef CONST_H_
#define CONST_H_

class Const:public Function {
    ....
public:
    Const(double x);
    ....
    Function::FunctionType getType();
    ....
    ~Const();
};

#endif /* CONST_H_ */

and its implementation:

//Const.cpp
#include "Const.h"
#include "Function.h"


Function::FunctionType Const::getType(){
    return Function::FunctionType::constant;
}
....

The compiler throw the following error:

error: ‘Function::FunctionType’ is not a class or namespace
return Function::FunctionType::constant;
                 ^

I'm not able to find out why I have this error, and what's wrong with this code that sounds to me easy and sound (and of course it is not).

3 Answers
Related