C++: expected identifier before numeric constant

后端 未结 3 2027
花落未央
花落未央 2020-12-21 02:20

I\'m trying to write a small program using MTL, but I\'m getting the mentioned error when I try to make a MTL Matrix a member of a class.

#include 

        
3条回答
  •  猫巷女王i
    2020-12-21 02:49

    You can't initialize variable within the class scope, you need to do it in a constructor. Change this:

    class myClass
    {
    private:
        mtl::dense2D Ke(6,6);
    };
    

    to this --

    class myClass
    {
    public:
        myClass() : Ke(6,6) { }
    private:
        mtl::dense2D Ke;
    };
    

提交回复
热议问题