Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class named Square. Define a getter and setter for it. Define a function to calculate the area. create 5 different objects (sq1, saq2,sq3,sq4
Create a class named Square.
Define a getter and setter for it.
Define a function to calculate the area.
create 5 different objects (sq1, saq2,sq3,sq4 and sq5).
For each square display its side and the area.
// classes example #include
using namespace std;
class Square {
int side;
public:
void setside(int s)
{
side = s;
}
int getside()
{
return side;
}
};
int main() {
Square sq1;
sq1.setside(10);
cout << "area: " << sq1.getside();
return 0;
}
HELP!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started