c++中struct的使用方法
来源:互联网 发布:java模块化开发思路 编辑:程序博客网 时间:2024/05/17 08:04
/*在C++里struct关键字与class关键字一般可以通用,只有一个很小的区别。struct的成员默认情况下属性是public的,而class成员却是private的。C++中struct中也可以有成员函数。*/struct Movie/*可以指定类型名也可以不指定*/{ //成员都是public的 intID; string Name;} movie; //可以在声明struct的时候声明一个struct实例int main(){ //movie变量在Movie结构声明处定义了 movie.ID = 100; movie.Name ="Face Off"; cout<<"movie.ID = "<<movie.ID<<endl; cout<<"movie.Name = "<<movie.Name<<endl; //声明一个变量m,无须为赋初值就可以使用它了 Movie m; m.ID = 101; m.Name ="多面双雄"; cout<<"m.ID="<<m.ID<<endl; cout<<"m.Name="<<m.Name<<endl; //声明结构的指针 Movie * mp; mp = &m; //在指针中调用成员时要用->符号,mp->ID等价于(*mp).ID cout<<"mp->ID = "<<mp->ID<<endl; cout<<"mp->Name = "<<mp->Name<<endl; }
0 0
- c++中struct的使用方法
- struct的使用方法
- C++struct tm 和 time_t 时间和日期的使用方法
- C/C++中typedef struct和struct的用法
- C/C++中typedef struct和struct的用法
- C/C++中typedef struct和struct的用法
- C#中struct和C中的struct的一个区别
- C/C++中typedef struct和struct的…
- C语言中struct和typedef struct的区别
- C/C++中typedef struct 和 struct的差异
- C语言中typedef struct与struct的区别
- C和C++中struct和typedef struct的分析
- C和C++中struct和typedef struct的分析
- C和C++中struct和typedef struct的异同
- C/C++中typedef struct和struct的区别
- C和C++中struct和typedef struct的异同
- C和C++中struct和typedef struct的异同
- C和C++中struct和typedef struct的分析
- javascript中原型模式创建对象特点分析
- Unity3D 资源管理 -- 基本概念
- HDU 4280 Island Transport 网络流
- 【OpenCV】双目测距(双目标定、双目校正和立体匹配)
- 从尾到头打印链表
- c++中struct的使用方法
- Retrofit+Rxjava的封装
- Java学习提要——日期处理类
- graphx与完全图
- 基于深度学习的人脸识别系统系列(Caffe+OpenCV+Dlib)——【五】设计人脸识别的注册类
- 算法学习笔记 - 冒泡排序
- python核心编程学习笔记-2016-09-11-01-Web编程(四)
- android中paint的用法
- HDU5538 House Building