error: no matching function for call to

Noob here..trying to learn concepts of CPP...
Could you please help me to figure this out.
here's the code

#include <iostream>
#include <iomanip>
using namespace std;

class rectangle{

private:
float length;
float width;

public:
rectangle(float = 0.0 , float = 0.0);
void showdata();
void setdata(float, float);
float perimeter(float, float);
float area(float, float);

};

rectangle::rectangle(float l , float w){
length = l;
width = w;
}

void rectangle::setdata(float l, float w){
length = l;
width = w;
}


void rectangle::showdata(){
cout << "Length = "<<length<<"\nWidth = "<<width<<endl;

cout<< "Perimeter = " << perimeter();

}

float rectangle::perimeter(float l, float w){

return(2*(l*w));
}

float rectangle::area(float l , float w){
return l*w;
}

int main(){

float ul;
float uw;

cout<<"Enter the length of the rectangle"<<endl;
cin>>ul;

cout<<"Enter the width the rectangle"<<endl;
cin>>uw;

rectangle recObj;

recObj.setdata(ul,uw);
recObj.showdata();

return 0;
}

I'm trying to output all by calling showdata()..but I get this error
error: no matching function for call to 'rectangle::perimeter()'

Please help...
error: no matching function for call to 'rectangle::perimeter()'


This error means that it cannot find a function perimeter(), in the rectangle class, which you are trying to call here:
cout<< "Perimeter = " << perimeter();
in the function
void rectangle::showdata(), which you called here:
recObj.showdata();


So, we look at the rectangle class. What do we see? We see a function rectangle::perimeter(float l, float w), but we don't see one rectangle::perimeter(). Perhaps you meant to call rectangle::perimeter(float l, float w)? Well, that function takes in two parameters, so you have to supply them when you call the function.

Last edited on
thank you soo much. I figured it out..
anyways, do u know how to use "ESC " TO exit a program??
Topic archived. No new replies allowed.