C++: expected identifier before numeric constant

后端 未结 3 2024
花落未央
花落未央 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条回答
  •  春和景丽
    2020-12-21 03:12

    Because when you declare

    mtl::dense2D Ke;
    

    you're only supposed to declare it, not create it yet. This is the constructor's job in C++:

    class myClass
    {
    public:
        myClass() // constructor
            : Ke(6, 6) // here we use the constructor initializer
        {
        }
    private:
        mtl::dense2D Ke; // declaration
    };
    

提交回复
热议问题