Question: Please add //comments to the below code so I can a good understanding of the functions. Thanks Circle.ccp #ifndef CIRCLE_H #define CIRCLE_H #include using namespace

Please add //comments to the below code so I can a good understanding of the functions. Thanks

Circle.ccp

#ifndef CIRCLE_H

#define CIRCLE_H

#include

using namespace std;

class Circle

{

private:

double radius;

public:

Circle()

{

radius = 1;//default value

}

void input()

{

cout << "Enter radius: ";

cin >> radius;

}

void print()

{

double PI = 3.14159;

double area = PI * radius * radius;

double circumference = 2 * PI * radius;

cout << "Circle with radius = " << radius << ", area = " << area << ", circumference = " << circumference << endl;

}

};

#endif // CIRCLE_H

Circle.h

#ifndef CIRCLE_H_INCLUDED

#define CIRCLE_H_INCLUDED

#include

using namespace std;

class Circle

{

private:

double radius;

public:

Circle()

{

radius = 1;//default value

}

void input()

{

cout << "Enter radius: ";

cin >> radius;

}

void print()

{

double PI = 3.14159;

double area = PI * radius * radius;

double circumference = 2 * PI * radius;

cout << "Circle with radius = " << radius << ", area = " << area << ", circumference = " << circumference << endl;

}

};

#endif // CIRCLE_H_INCLUDED

Square.ccp

#include "square.h"

Square::Square(double _a, double _b)

{

a = _a;

b = _b;

}

void Square::print() const

{

std::cout << "First side: " << a << std::endl;

std::cout << "Second side: " << b << std::endl;

std::cout << "Area: " << area() << std::endl;

}

double Square::area() const

{

return a*b;

}

void Square::input()

{

std::cout << "Enter side 1: "; std::cin >> a;

std::cout << "Enter side 2: "; std::cin >> b;

}

Square.h

#endif // SQUARE_H_INCLUDED

#ifndef SQUARE_H_INCLUDED

#define SQUARE_H_INCLUDED

#include

class Square

{

private:

double a;

double b;

public:

Square(double _a = 0.0, double _b = 0.0);

void print() const;

double area() const;

void input();

};

#endif // SQUARE_H_INCLUDED

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!