摘要: operator++(int) 和 operator++() 是 C++ 中重载的两个不同的自增运算符函数,它们分别用于后置自增和前置自增。它们的区别在于调用方式以及自增行为的不同。 1. 前置自增运算符 operator++(): 函数签名: Type& operator++(); 调用方式: + 阅读全文
posted @ 2024-09-27 21:10 牛马chen 阅读(282) 评论(0) 推荐(0)
摘要: 在 C++ 中,const 关键字可以应用于成员函数,表示该函数不会修改对象的成员变量。 const 出现在 operator->() 成员函数的末尾,这意味着该成员函数在调用时不会修改对象的任何成员变量。 如下: node* operator->() const { return p; } 1. 阅读全文
posted @ 2024-09-27 21:03 牛马chen 阅读(103) 评论(0) 推荐(0)
摘要: 初始化类成员的两种方式:(1)使用初始化列表;(2)在构造函数体内进行赋值操作。 class Point { public: Point(int xx, int yy) : x(xx), y(yy) { cout << "Constructor of Point" << endl; } privat 阅读全文
posted @ 2024-09-27 15:20 牛马chen 阅读(52) 评论(0) 推荐(0)