gpt4 book ai didi

c++ - 错误 : "className" is not a nonstatic data member or base class of class "className"

转载 作者:行者123 更新时间:2023-11-30 00:45:57 34 4
gpt4 key购买 nike

我正在尝试创建一个调用默认构造函数的显式构造函数,但它说我没有。

class Paddle{
private:

int x, y;
int startX, startY;

public:

Paddle(){
x = y = 0;
}

Paddle(int posX, int posY) : Paddle(){ // <-- the error is on ": Paddle()"
startX = posX;
startY = posY;
x = posX;
y = posY;
}
};

究竟是什么导致了这种情况发生,我该如何解决?提前致谢!

最佳答案

这是正确的语法,但是直到 C++11 才支持构造函数委托(delegate)

Visual Studio 2012 并不旨在实现 C++11 标准。构造函数委托(delegate)是支持的事情之一。

关于c++ - 错误 : "className" is not a nonstatic data member or base class of class "className",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40789370/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com