首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手有关问题③

2012-03-23 
新手问题③#includeiostream#includefile.h usingnamespacestdmain(){rectangleafloati,jcin i

新手问题③
#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 ;

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

热点排行