Calling virtual functions inside constructors

前端 未结 13 1034

Suppose I have two C++ classes:

class A
{
public:
  A() { fn(); }

  virtual void fn() { _n = 1; }
  int getn() { return _n; }

protected:
  int _n;
};

clas         


        
13条回答
提交回复
热议问题