What is the error in the following declaration of a constructor for the class Rectangle? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the error in the following declaration of a constructor for the class Rectangle?

https://code.sololearn.com/c8us8lEF3ioi/?ref=app

24th Sep 2020, 4:10 PM
Tiara Feryndita Astuti
Tiara Feryndita Astuti - avatar
3 Answers
+ 6
Your code is looking incomplete first read basic concepts like how to make class how to call functions......etc after that u can make easily. This is your program. #include <iostream> using namespace std; class Rectangle { public: int area; void Area(int length, int breadth) { area =length*breadth ; cout<<"Area of Rectangle is "<<area; } }; int main() { Rectangle area; area.Area(5,4); }
24th Sep 2020, 5:18 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
There is no class. No member declaration. Revisit this part of the course. https://www.sololearn.com/learn/CPlusPlus/1711/
24th Sep 2020, 4:14 PM
Avinesh
Avinesh - avatar
0
Avinesh thanks a lot ^^
24th Sep 2020, 5:02 PM
Tiara Feryndita Astuti
Tiara Feryndita Astuti - avatar