一、C++带普通参数的构造函数
#include <iostream>
using namespace std;
class Box
{
public:
Box(int, int, int); //声明带参数的构造函数
int Volume(); //声明计算体积的构造函数
private: //私有数据部分定义长宽高的变量
int height;
int width;
int length;
};
//定义Box类的构造函数 ,带有3个参数
Box::Box(int h, int w, int len)
{
height= h; //对私有成员进行初始化
width= w;
length= len;