注册 登录
编程论坛 C++教室

我的程序为什么会出现function does not take 1 parameters这样的错误

走自己路的人 发布于 2007-04-17 23:19, 2759 次点击

#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

1 回复
#2
aipb20072007-04-17 23:33

float setLength(void)const;

float setWidth(void)const;



你自己声明的函数参数表是空的,用的时候你又用上了参数,当然会错!

1