c++ compiling “error: expected constructor, destructor, or type conversion before '=' token ”

后端 未结 4 462
暖寄归人
暖寄归人 2021-01-19 03:55

Very simple codes located in the same file \'foo.h\':

class Xface
{
  public:
    uint32_t m_tick;
    Xface(uint32_t tk)
    {
      m_tick=tk;
    }
}

std         


        
4条回答
  •  长发绾君心
    2021-01-19 04:35

    You have no default constructor. You need to have a constructor that doesn't need any arguments. Right now, you've got a constructor that needs a uint32_t, so you can't new an array of them. Not to mention, as Neil pointed out, the missing semicolon, and gruszczy's observation that executable code needs to be in a function.

提交回复
热议问题