C++利用结构
2015-09-23 21:34
453 查看
#include <iostream> using std::cout; using std::endl; //定义结构 struct Box{ double length; double width; double height; }; double volume(const Box& aBox); int main(){ Box box={70.0,60.0,40.0}; double boxVolume=volume(box); cout << "Size of box is:"<<endl << "length:"<<box.length<<endl <<"width:"<<box.width<<endl <<"height:"<<box.height<<endl; cout <<"Voluem of box is:"<<boxVolume<<endl; return 0; } //计算体积的函数 double volume(const Box& box){ return box.length*box.width*box.height; }
相关文章推荐
- 玩转Google开源C++单元测试框架Goo…
- c++继承与派生
- c语言学习笔记(5)enum和typedef分析
- 输入十个数,输出其中最大的一个数
- c++primer第三章习题(2)
- C++ *max_element函数找最大元素 *min_element函数找最小元素 STL算法(转)
- 黑马程序员------C语言函数部分总结(一)
- More Effective C++ 条款18 分期摊还预期的成本
- 项目24.1分段函数求值
- 【C语言】交换两个数的内容
- POJ C++程序设计 编程题#9:人群的排序和分类
- C++this指针、智能指针
- C++语言const修饰指针
- C++习题二第12题
- 文章标题
- 蓝桥杯 地宫寻宝 带缓存的DFS
- Effective C++——条款53(第9章)
- VC++编译器调试(一)
- POJ C++程序设计 编程题#7:字符串排序
- C++函数返回引用