摘要: 1. 如果对象不是针对,它们没有区别 2. 如果对象是指针,它们有区别 : 指针p不能够指向其他地址 : 指针p只读 ,不能够对其进行修改 举例, include using namespace std; int main() { int arr[3]={1,2,3}; int varr[3]={1 阅读全文
posted @ 2019-12-25 22:50 2021年的顺遂平安君 阅读(7930) 评论(0) 推荐(1)
摘要: 如果对象不是针对,它们没有区别 int const x = 3;const int x = 3; 如果对象是指针,它们有区别 int* const p = &array: 指针p不能够指向其他地址 const int* p = &array: 指针p只... 阅读全文
posted @ 2019-12-25 22:50 2021年的顺遂平安君 阅读(79) 评论(0) 推荐(0)
摘要: 两者基本相似,语法也相同。两者不同点在于,类中成员默认是private的,而结构体中成员默认是public的。 阅读全文
posted @ 2019-12-25 22:01 2021年的顺遂平安君 阅读(96) 评论(0) 推荐(0)
摘要: 两者基本相似,语法也相同。两者不同点在于,类中成员默认是 的,而结构体中成员默认是 的。 阅读全文
posted @ 2019-12-25 22:01 2021年的顺遂平安君 阅读(369) 评论(0) 推荐(0)
摘要: 网上看了很多说明,还是处于半知半解的状态,看了下面这个例子才算是明白了 指针 include using namespace std; class Box { public: // Constructor definition Box(double l = 2.0, double b = 2.0, 阅读全文
posted @ 2019-12-25 21:56 2021年的顺遂平安君 阅读(393) 评论(0) 推荐(0)
摘要: 网上看了很多说明,还是处于半知半解的状态,看了下面这个例子才算是明白了this指针 #include using namespace std;class Box { public: // Constructor definition ... 阅读全文
posted @ 2019-12-25 21:56 2021年的顺遂平安君 阅读(66) 评论(0) 推荐(0)
摘要: const放在最前面用于修改函数返回值时,并没有实际效果,因为函数返回值以复制的形式被赋给变量。const放在形参列表后面时,表明该函只能够”只读“其所在的类,不能够访问所在类的其他非只读成员函数。 阅读全文
posted @ 2019-12-25 06:05 2021年的顺遂平安君 阅读(64) 评论(0) 推荐(0)
摘要: 1. 放在最前面用于修改函数返回值时,并没有实际效果,因为函数返回值以复制的形式被赋给变量。 2. 放在形参列表后面时,表明该函只能够”只读“其所在的类,不能够访问所在类的其他非只读成员函数。 阅读全文
posted @ 2019-12-25 06:05 2021年的顺遂平安君 阅读(202) 评论(0) 推荐(0)
摘要: ``` include using namespace std; int main() { int arr[2][2][2] = {0}; for(auto&& i:arr) for(auto&& j:i) for(auto&& k:j) cout 阅读全文
posted @ 2019-12-25 04:12 2021年的顺遂平安君 阅读(431) 评论(0) 推荐(0)
摘要: #include using namespace std;int main(){ int arr[2][2][2] = {0}; for(auto&& i:arr) for(auto&& j:i) for(auto&& k:j) cout <<... 阅读全文
posted @ 2019-12-25 04:12 2021年的顺遂平安君 阅读(105) 评论(0) 推荐(0)
摘要: begin(a)指向数组a的第一个元素,end(a)指向数组a最后一个元素之后的一个元素 #include using namespace std;int main(){ int ia[] = {0,1,2,3}; int *beg = begin(ia... 阅读全文
posted @ 2019-12-25 04:02 2021年的顺遂平安君 阅读(187) 评论(0) 推荐(0)
摘要: `begin(a) a`的第一个元素, 指向数组 最后一个元素 之后的一个元素 include using namespace std; int main() { int ia[] = {0,1,2,3}; int beg = begin(ia); int last = end(ia); cout 阅读全文
posted @ 2019-12-25 04:02 2021年的顺遂平安君 阅读(3851) 评论(0) 推荐(0)
摘要: ``` include using namespace std; int main() { int ia{3}; decltype(ia) varr[3]={1,2,3}; for(auto&& x:varr) cout 阅读全文
posted @ 2019-12-25 03:53 2021年的顺遂平安君 阅读(165) 评论(0) 推荐(0)
摘要: #include using namespace std;int main(){ int ia{3}; decltype(ia) varr[3]={1,2,3}; for(auto&& x:varr) cout << x << endl; return ... 阅读全文
posted @ 2019-12-25 03:53 2021年的顺遂平安君 阅读(57) 评论(0) 推荐(0)
摘要: #include using namespace std;void printReference (int& value){ cout << "lvalue: value = " << value << endl;} void printRe... 阅读全文
posted @ 2019-12-25 03:49 2021年的顺遂平安君 阅读(98) 评论(0) 推荐(0)
摘要: ``` include using namespace std; void printReference (int& value) { cout 阅读全文
posted @ 2019-12-25 03:49 2021年的顺遂平安君 阅读(275) 评论(0) 推荐(0)