0
how to Write a class having two public variables and one member function which will return the area of the rectangle in c++
4 Réponses
+ 1
class rectangle {
public :
int length,width;
int area()
{
return= length*width;
}
};
void main()
{
rectangle r;
r.length=6;
r.width=7;
cout<<r.area();
}
+ 4
class rectangle {
public :
int length,width;
int area()
{
return length*width;
}
};
int main()
{
rectangle r;
r.length=6;
r.width=7;
cout<<r.area();
}
+ 1
Idk about c++ but I see that return = length * width should be: return length * width
As return is a keyword not a variable so don’t use the =
0
Show your attempt, you can't just give the question and get answers. Provide your code and tell exactly where you're stuck. All the best =)