C++ 复合类型
来源:互联网 发布:孤岛惊魂2的画面优化 编辑:程序博客网 时间:2024/05/16 05:28
struct Student{ std::string name; int age;};//定义Student1的时候创建变量std1struct Student1{ std::string name; int age;}std1;//定义无名机构体的时候创建变量std0struct{ std::string name; int age;}std0;struct _student{ std::string name; int age; _student(std::string _name,int _age) { name = _name; age = _age; }};
int num[3]; num[0] = 1; num[1] = 2; num[2] = 3; for(int i : num) { log("This is %d", i); } int arr[3] = {4, 5, 6}; log("Size of int is %lu", sizeof(int));//4 log("Size of arr is %lu", sizeof(arr));//12 int arr1[] = {7,8,9};//编译器会帮你算个数的,但是不推荐。 int arr2[100] = {0};//只要显示的初始化第一个元素,编译器就会把其他的元素都初始化为0 //c++11新特性 int c11_1[3] {5, 2, 0};//可以省略等于号 int c11_2[3] {};//可以不在括号里写任何东西,这将把所有元素都设置为0 std::string love {"zhouyunxuan"}; //struct std1.name = "yunxuan"; std1.age = 21; Student stu2 = { "zhouyunxuan", 21 }; Student stu3 {"yunxuan", 21}; //创建动态数组 int idx = 10; int* p = new int[idx]; for (int i = 0; i < 10; ++i) { p[i] = i*100; } for (int i = 0; i < 10; ++i) { log("this is %d", p[i]); } _student ss("YUNXUAN", 21); log("my name is %s", ss.name.c_str());
//结构体函数typedef struct _student{ std::string name; int age; _student(const char * _name):name(_name){ printf("%s\n", name.c_str()); }}Student;
0 0
- C++:复合类型
- 【c++】复合类型
- C++Primer之复合类型
- 1.5 c++_复合类型
- 学习C++——复合类型
- [c++primeplus6th]-第4章.复合类型
- 《c++primer笔记》复合类型--引用
- c++primer笔记--2.3复合类型
- c++primer学习笔记-----2.3复合类型
- c++primer plus复合类型之枚举
- c++primer plus复合类型之指针
- 复合类型
- 复合类型
- 复合类型
- c语言中的类型转换与复合类型
- c语言中的类型转换与复合类型
- C语言学习笔记(4)类型转化,复合类型
- c++primerP29-----P51 基本内置类型,变量,复合类型
- Dos命令删除添加新服务
- 闭包相关的实例
- ERROR: HHH000196: Error parsing XML (4) :
- OCP 1Z0 053 153
- [iOS diary]iOS在非主线程运行主线程的方法
- C++ 复合类型
- JSON.parse()和JSON.stringify()
- myeclipse安装svn插件
- (原创)项目中都会用到的条件查询底层方法实现,有点复杂,慢慢道来!
- 清华大学留学班2014年招生--美加英澳名校直通车
- 如何安装pip--python的包管理工具
- Codeforces Round #FF (Div. 2/C)/Codeforces446A_DZY Loves Sequences(DP)
- 免费视频监控软件ZoneMinder的使用(持续更新中)
- 【ROLLUP】Oracle分组函数之ROLLUP魅力