C++中对象指针的使用
来源:互联网 发布:linux运维常用脚本 编辑:程序博客网 时间:2024/05/17 20:00
//定义结构
Box.h:
#ifndef BOX_H#define BOX_Hstruct Box{double length;double width;double height;double volume();};#endif
//定义volume方法
t1.cpp:
#include "box.h"double Box::volume(){return length*width*height;}
test.cpp:
#include <iostream>using std::cout;using std::endl;#include "box.h"int main(){Box box={70.0,60.0,40.0};Box* pBox=&box;cout<<endl<<"Volume is:"<<pBox->volume()<<endl;Box* pdBox=new Box;pdBox->height=pBox->height+5.0;pdBox->length=pBox->length-2.0;pdBox->width=pBox->width-2.0;cout<<"Volume is:"<<pdBox->volume()<<endl;delete pdBox;return 0;}
0 0
- C#中对象指针的使用
- C++中对象指针的使用
- 类中使用对象指针的形式
- C中指针使用
- c语言中指针的使用场合
- c语言中指针的使用场合
- c语言中指针的使用【一】
- C语言中数组指针的使用
- c中函数指针的使用
- C 中typedef 函数指针的使用
- 关于C中指针使用的注意事项
- 第二十章,对象指针及this的使用(C++)
- c中指针的指针
- 指向对象的指针【c++】
- 【C++】指针的使用
- C中使用面对对象的思想
- 有关对象指针的使用
- C中双重指针的使用的易错点
- linux 打开外部传送来的文件中文乱码问题解决
- PriorityQueue 的概念及其使用
- poj 3177 Redundant Paths 边双连通分量+缩点
- Ext中apply及applyIf方法的应用
- js 实现封装
- C++中对象指针的使用
- 程序员面试之性格篇
- freemarker 数值和类型
- CoreData-实现数据永久性保存时遇到的问题
- JS字符串方法扩展
- maven nexus 的私服搭建
- 在控制台程序中使用MFC类
- C#模拟http 发送post或get请求
- Javascript面向对象研究心得