源程序:
#include <iostream>
using namespace std;
class Test
{
private:
int Width,Height;
public:
//以下是函数
void SetValue(int iWidth,int iHeight)
{
Width=iWidth;
Height=iHeight;
}
float GetValue(void)
{
return Width*Height;
}
};
int main()
{
Test T;
T.SetValue(10,20);
cout<<T.GetValue()<<endl;
return 1;
}
运行结果:200