#include<iostream> using namespace std; class Point { private: int x,y; public: void SetPoint(int

怎么改
2024-12-31 15:14:27
推荐回答(1个)
回答1:

#include
using namespace std;
class Point {
private:
int x,y;
public:
void SetPoint(int x,int y);
};
啥怎么改?怎么写一个类么?
定义类:
.h文件:
class mybox
{
private:
double length;
double height;
double width;
public:
mybox(double lval=1,double hval=1,double wval=1);
~mybox(void);
double volume() ;
};

.cpp文件:

#include "mybox.h"
//构造函数
mybox::mybox(double lval,double hval,double wval)
{
length=lval;
height=hval;
width=wval;
}
double mybox::volume()
{
return length*height*width;
}

mybox::~mybox(void)
{
}