首页 > 编程语言 > 详细

C++中的结构的使用

时间:2014-07-11 08:37:36      阅读:332      评论:0      收藏:0      [点我收藏+]
#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;
}


C++中的结构的使用,布布扣,bubuko.com

C++中的结构的使用

原文:http://blog.csdn.net/u010142437/article/details/37653469

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!