when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.
类的成员包括成员变量和成员函数
他们的访问权限由 pulibc、protected、private 决定,省略不写时(默认)等同于 private
静态成员变量是一种特殊的成员变量,它以关键字 static 开头,这种成员变量的生存期大于 class 的对象(instance)。静态成员变量是每个 class 有一份,普通数据成员是每个对象各自拥有一份,因此静态成员变量也叫做类变量
1 | class Test |
c++11 中的 auto 是一个占位符,编译器在编译期间自动推导出变量的类型,并适当地改变结果类型使其更符合初始化规则,因此 auto 定义的变量必须有初始值
1 | int x; |
搭建 Git 服务器
1 | $ mkdir test.git # 创建 Git 资源的存储目录 test.git |
1
2
3
4
5
6
7
8
9
10
11
12struct child
{
char name[10];
};
struct child she = { "Jerry" };
int main()
{
static struct child she1 = { "Jerry1" };
struct child she2 = { "Jerry2" };
return 0;
}
std::variant 是 C++17 中一个新加入标准函式库的 template 容器,使用时需要 #include
它的概念基本上是和 union 一样,是一个可以用来储存多种型别资料的容器;和 union 不同的是,std::variant 是 type-safe 的,再加上有许多函数可以搭配使用,所以在使用上应该算是相对安全
由于它是标准函式库的 template class,在使用时不需要另外去宣告一个新的类型
std::variant 在储存数据的时候,内部会有一个索引值来记录目前存储的是哪一个类型的数据
the only present love demands is love