C++ primer 第七章 练习7.35 类作用域练习

修复后的代码:

在Type前面加上类作用域Exercise::Type,

然后定义声明的函数initVal()

typedef string Type;
Type initVal();
class Exercise {
public:
    typedef double Type;
    Type initVal() {
        return val;
    };
    Type setVal(Type);
private:
    Type val;
};

Exercise::Type Exercise::setVal(Type parm) {
    val = parm + initVal();
    return val;
}
 
原文地址:https://www.cnblogs.com/--zz/p/10450277.html