0

how to Write a class having two public variables and one member function  which will return the area of the rectangle in c++

29th Oct 2021, 4:12 PM
Younis Ahmad
Younis Ahmad - avatar
4 odpowiedzi
+ 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(); }
29th Oct 2021, 4:37 PM
Younis Ahmad
Younis Ahmad - avatar
+ 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(); }
29th Oct 2021, 6:29 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar
+ 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 =
29th Oct 2021, 6:28 PM
Guillem Padilla
Guillem Padilla - avatar
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 =)
29th Oct 2021, 4:20 PM
Rishi
Rishi - avatar