我从2年左右开始做C++,我说为什么我们需要类中的构造函数而不是结构中的构造函数,以及为什么我们不能在结构中进行构造函数重载...
为什么我们需要在课堂上施工
我们没有.
// Perfectly valid
class Foo
{
public:
int x
};
Run Code Online (Sandbox Code Playgroud)
为什么我们不能在结构中进行构造函数重载...
我们可以.
// Look, ma!
struct Bar
{
Bar operator+(const Bar& other);
};
Run Code Online (Sandbox Code Playgroud)
我不知道你在哪里听到这些说法,但肯定不是试了这个.