7.23带参数的构造函数
来源:互联网 发布:网络侦探进化 编辑:程序博客网 时间:2024/05/30 04:27
/*带参数的构造函数*/
#include<iostream>
using namespace std;
class Box{
public:
Box(float L,float W,float H)
{length=L;width=W;height=H;}
float volume(){return length*width*height;}
private:
float length;float width;float height;
};
int main()
{
Box box1(1,2,3);
Box box2(5,1,2);
cout<<box1.volume()<<endl;
cout<<box2.volume()<<endl;
return 0;
}
#include<iostream>
using namespace std;
class Box{
public:
Box(float L,float W,float H)
{length=L;width=W;height=H;}
float volume(){return length*width*height;}
private:
float length;float width;float height;
};
int main()
{
Box box1(1,2,3);
Box box2(5,1,2);
cout<<box1.volume()<<endl;
cout<<box2.volume()<<endl;
return 0;
}
0 0
- 7.23带参数的构造函数
- 带参数的构造函数
- 带参数的构造函数
- 带参数的构造函数
- 带参数的构造函数
- 带参数的构造函数.cpp
- C#带参数的构造函数
- Qt 带自定义参数的构造函数
- 带默认参数的构造函数
- 三角形类的构造函数-使用带参数构造函数
- Java 带参数构造函数
- C++构造函数—构造函数的声明与定义、带参数的构造函数
- 带参数的构造函数及使用默认参数的构造函数
- 类的继承中带参数的构造函数
- 调用父类的带参数的构造函数
- Fragment使用带参数的构造函数遇到的问题
- Javascript中带参数的构造函数的执行过程
- C#中怎样学好带参数的构造函数
- 一个字符串的第一个字母与另外的一串字母的样式
- 两个栈实现队列+两个队列实现栈----java
- 内联元素
- 制作动画序列帧
- 黑马程序员—银行业务调度系统
- 7.23带参数的构造函数
- 7.30-2014新生暑假个人排位赛08
- Linux(历史)命令用法 15 例
- 深入理解java异常处理机制
- dfhfdfsf
- 2014新生暑假个人排位赛08
- 地方和天然估计一天天然合同
- 深度探索C++对象模型--继承与Data Member
- KMP算法