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;
}

 

 
posted @ 2019-02-28 14:39  zz2108828  阅读(432)  评论(0编辑  收藏  举报