小编lag*_*ha6的帖子

C++ 指针返回 0 值

我对 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)

c++ pointers

2
推荐指数
1
解决办法
93
查看次数

标签 统计

c++ ×1

pointers ×1