小编ago*_*uil的帖子

C++继承 - 子类构造函数调用?

我主要有以下内容:

Sum *sum = new Sum(Identifier("aNum1"), Identifier("aNum2"));
Run Code Online (Sandbox Code Playgroud)

我的课程是:

class Table {
private:
    static map<string, int> m;    
public:
    static int lookup(string ident)
    {
        return m.find(ident)->second;
    }
    static void insert(string ident, int aValue)
    {
        m.insert(pair<string, int>(ident, aValue));
    }
};   

class Expression {
public:
    virtual int const getValue() = 0;
};

class Identifier : Expression {
private:
    string ident;
public:
    Identifier(string _ident) { ident = _ident; }
    int const getValue() { return Table::lookup(ident); }    
};

class BinaryExpression : public Expression {
protected:
    Expression …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance constructor object-slicing

2
推荐指数
1
解决办法
670
查看次数

标签 统计

c++ ×1

constructor ×1

inheritance ×1

object-slicing ×1