C++ c++;公共成员只有在构造函数具有参数时才可访问

C++ c++;公共成员只有在构造函数具有参数时才可访问,c++,most-vexing-parse,C++,Most Vexing Parse,所以我创建了这个类,它包含一些布尔型的公共成员,但是,当我实际尝试使用默认构造函数(没有参数)创建对象时,我无法访问这些成员。但是,如果使用参数(unsigned int)声明构造函数,则可以访问成员。有人知道这是为什么吗 以下是课程: class MoveManagement { private: Player * currentPlayer; sf::View* currentView; int lambda_x = 0; int lambda_y = 0;

所以我创建了这个类,它包含一些布尔型的公共成员,但是,当我实际尝试使用默认构造函数(没有参数)创建对象时,我无法访问这些成员。但是,如果使用参数(unsigned int)声明构造函数,则可以访问成员。有人知道这是为什么吗

以下是课程:

class MoveManagement {

private:
    Player * currentPlayer;
    sf::View* currentView;
    int lambda_x = 0;
    int lambda_y = 0;

public:
    bool m_up;
    bool m_down;
    bool m_left;
    bool m_right;

    MoveManagement() {
        m_up = false;
        m_down = false;
        m_left = false;
        m_right = false;
    }

    void getNextView(Player* player_, sf::View* view_) {
        currentPlayer = player_;
        currentView = view_;

        if (m_up) {
            --lambda_y;
        }

        if (m_down) {
            ++lambda_y;
        }

        if (m_left) {
            --lambda_x;
        }

        if (m_right) {
            ++lambda_x;
        }

        currentPlayer->playerCharacter->m_position.x = currentPlayer->playerCharacter->m_position.x + lambda_x;
        currentPlayer->playerCharacter->m_position.y = currentPlayer->playerCharacter->m_position.y + lambda_y;

        currentView->move(lambda_x, lambda_y);

        lambda_x = 0;
        lambda_y = 0;
    }
};
我创建一个新对象,如下所示:

MoveManagement move();
如果我试图访问任何成员,我会得到一个错误,说“表达式必须有类类型”


谢谢。

移动管理移动()声明一个函数。使用
移动管理移动

您声明了一个函数,但没有调用默认构造函数,这是一个函数声明,不是构造函数调用-省略括号。非常感谢!