#include<iostream.h>
class cfx
{
private:
float length;
float width;
public:
cfx(float l=1,float w=1):
length(l),width(w)
{}
~cfx()
{}
cfx zc(const cfx l)const;
cfx area(const cfx l)const;
void show(void)const;
float getLength(void)const;
float getWidth(void)const;
float setLength(void)const;
float setWidth(void)const;
};
float cfx::getLength(void)const
{ return length;
}
float cfx::getWidth(void)const
{ return width;
}
cfx cfx::zc(const cfx l)const
{ cfx c;
c=2*length+2*l.width;
return c;
}
cfx cfx::area(const cfx l)const
{ cfx c;
c=length*l.width;
return c;
}
void main(void)
{ cfx length(12),width(5),z1,z2;
length.setLength(11);
width.setWidth(6);
z1=length.zc(width);
z2=length.area(width);
cout<<"z1 is"<<z1.getLength()<<endl;
cout<<"z2 is"<<z2.getWidth()<<endl;
}
错误显示:D:\Program Files\Microsoft Visual Studio\MyProjects\Exam3_32\Exam3_32.cpp(78) : error C2660: 'setLength' : function does not take 1 parameters
D:\Program Files\Microsoft Visual Studio\MyProjects\Exam3_32\Exam3_32.cpp(80) : error C2660: 'setWidth' : function does not take 1 parameters