11 2022 档案

C++中的几种构造函数和析构函数
摘要:本篇文章,我们来了解一下C++中的几种构造函数,以及析构函数 #include <format> #include <iostream> #include <string> using std::format; using std::cout; using std::string; const st 阅读全文

posted @ 2022-11-28 16:06 新西兰程序员 阅读(94) 评论(0) 推荐(0) 编辑

C++中class中对私有变量的访问
摘要:C++中写class时,对私有变量通常使用set和get方法来进行访问,比较标准的例子 class A { int ia {}; int ib {}; int ic {}; public: A (int a, int b, int c) : ia(a), ib(b), ic(c) {} //构造函数 阅读全文

posted @ 2022-11-28 15:06 新西兰程序员 阅读(235) 评论(0) 推荐(0) 编辑

C++中Function里面的call by value 和 call by reference
摘要:先来看看C++中call by value的function void func(int a) { ++a; } int main(){ int a {7}; func(a); cout << format("value is {}\n",a); //a 会输出7 } c++中call by ref 阅读全文

posted @ 2022-11-28 13:44 新西兰程序员 阅读(129) 评论(0) 推荐(0) 编辑

C++中的Pointer member dereference(D-reference) operator
摘要:在C++中,比如我们可以把一个结构体struct的地址赋给一个指针pointer 然后使用这个指针去访问这个结构体中的元素时,可以使用pointer member D-reference operator: -> 用来access a member through a pointer #includ 阅读全文

posted @ 2022-11-28 11:24 新西兰程序员 阅读(29) 评论(0) 推荐(0) 编辑

C++中的Type Alias 和 Primitive Arrays 和 Primitive C-string
摘要:在C++中,我们通常使用typedef来实现type alias. 比如: #include <cstdint> //C standard int typedef uint32_t points_t; //points_t is alias of uint32_t typedef uint64_t 阅读全文

posted @ 2022-11-24 16:16 新西兰程序员 阅读(70) 评论(0) 推荐(0) 编辑

C语言中union类型学习
摘要:union指的是C语言的共用体(联合体) a union is a container of overlapping object 共用体它表示几个变量共用同一个内存位置, 在不同的时间保存不同的数据类型和不同长度的变量 union中,里面全部的共用体成员共用同一个内存空间, 而且特别重要的一点是: 阅读全文

posted @ 2022-11-21 17:02 新西兰程序员 阅读(363) 评论(0) 推荐(0) 编辑

C++中的Struct和Class异同
摘要:C++中为了和语言兼容,保留了C语言中的struct关键字,并且进行了适当扩充. C语言 => struct只是包含成员变量,但不包括成员函数 C++中 => struct和class非常类似,既可以包括成员变量,又可以包括成员函数 也就是说C++中,struct和class基本上是可以通用的,只有 阅读全文

posted @ 2022-11-21 16:34 新西兰程序员 阅读(49) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示