
c++的一个问题no matching function for call to 求解
#include<iostream>usingnamespacestd;classrectangle{doublewidth;doublelength;public:re...
#include <iostream>
using namespace std;
class rectangle{
double width;
double length;
public:
rectangle(double w,double l);
rectangle(const rectangle& p);
void perimeter(double w,double l);
void square(double w,double l);
};
rectangle::rectangle(double w,double l){
width=w;
length=l;
}
rectangle::rectangle(const rectangle &p)
{ length=p.length;
width=p.width;
}
inline void rectangle::perimeter(double w,double l)
{ cout<<(2*width)+(2*length)<<endl;
}
inline void rectangle::square(double w,double l)
{ cout<<width*length<<endl;
}
int main(){
int n;
cin>>n;
double wid,len;
while(n--)
{
cin>>wid>>len;
rectangle p(wid,len);
p.perimeter();
p.square();
}
return 0;
}最后两行那里显示no matching function for call to 什么意思,求大神解救 展开
using namespace std;
class rectangle{
double width;
double length;
public:
rectangle(double w,double l);
rectangle(const rectangle& p);
void perimeter(double w,double l);
void square(double w,double l);
};
rectangle::rectangle(double w,double l){
width=w;
length=l;
}
rectangle::rectangle(const rectangle &p)
{ length=p.length;
width=p.width;
}
inline void rectangle::perimeter(double w,double l)
{ cout<<(2*width)+(2*length)<<endl;
}
inline void rectangle::square(double w,double l)
{ cout<<width*length<<endl;
}
int main(){
int n;
cin>>n;
double wid,len;
while(n--)
{
cin>>wid>>len;
rectangle p(wid,len);
p.perimeter();
p.square();
}
return 0;
}最后两行那里显示no matching function for call to 什么意思,求大神解救 展开
2个回答
展开全部
p.perimeter();
p.square();
这两个调用的时候,需要传参数进去。改成
p.perimeter(wid,len);
p.square(wid,len);
或者在main上边在加上两个没参数的函数
inline void rectangle::perimeter()
{ cout<<(2*width)+(2*length)<<endl;
}
inline void rectangle::square()
{ cout<<width*length<<endl;
}
2016-06-05
展开全部
你的现在输入的参数是string类类型,需要char*类型,可以使用string的c_str()成员函数来获得char*改成:if(strcmp(stu[j].num.c_str(),stu[max].num.c_str())>0)
追问
谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询