读书人

新手有关问题③

发布时间: 2012-03-23 12:06:21 作者: rapoo

新手问题③
#include <iostream>
#include "file.h "
using namespace std;
main()
{
rectangle a ;
float i,j;
cin> > i> > j ;
cout < < "矩形面积: " < <a.length1(i,j) < <endl ;


}

// file.h

class rectangle
{
public:
rectangle() ;
~rectangle() ;
float length1(float i,float j) ;

private:
float length ;
float width ;

}

rectangle::rectangle()
{
length=0.0;
width=0.0;

}

rectangle::~rectangle()
{

}

float rectangle::length1(float i,float j)
{
length=i;
width=j ;
float acreage;
acreage=length*width ;
return acreage ;

}


////////////////////////////////////////////////////////////////
。。。哎。。郁闷。。。。编译都没有通过。。。!~请高手帮忙把编译过了。。!~谢谢了。!~

[解决办法]
private:
float length ;
float width ;

}; // 类定义后面要加分号

读书人网 >C++

热点推荐