我对 C++ 很陌生,而且我有指针问题。有人可以解释一下这个代码如何为 y 返回 0 而不是 20 吗?
#include <iostream>
using namespace std;
class Test
{
private:
int x;
int y;
public:
Test (int x = 0, int y = 0) { this->x = x; this->y = y; }
Test setX(int a) { x = a; cout << "hello"; return *this; }
Test setY(int b) { y = b; cout << "world"; return *this; }
void print() { cout << "x = " << x << " y = …
Run Code Online (Sandbox Code Playgroud)