A class in a namespace

Source File: Main.cpp

#include <iostream>

using namespace std;



const double PI = 3.14159;



namespace FlatShapes

{

    class Circle

    {

    public:

        void setRadius(const double r);

        double getRadius() const;

        double Diameter() const;

        double Circumference() const;

        double Area() const;

    private:

        double Radius;

    };



	class Square

	{

	private:

		double Side;

	public:

		void setSide(const double s) { Side = s; }

		double getSide() const { return Side; }

		double Perimeter() const { return Side * 4; }

		double Area() const { return Side * Side; }

	};

}



namespace FlatShapes

{

	void FlatShapes::Circle::setRadius(const double r)

	{

		Radius = r; 

	}



	double FlatShapes::Circle::getRadius() const

	{

		return Radius;

	}



	double FlatShapes::Circle::Diameter() const

	{

		return 2 * Radius; 

	}



	double FlatShapes::Circle::Circumference() const

	{

		return 2 * Radius * PI; 

	}



	double FlatShapes::Circle::Area() const

	{

		return Radius * Radius * PI;

	}

}



int main()

{

    FlatShapes::Circle Round;

	

	Round.setRadius(20.62);



    cout << "Characteristics of the circle";

    cout << "\nRadius: " << Round.getRadius();

    cout << "\nDiameter: " << Round.Diameter();

    cout << "\nCircumference: " << Round.Circumference();

    cout << "\nTotal Area: " << Round.Area();    

    

	FlatShapes::Square Sous;



	Sous.setSide(42.28);

	cout << "\n\nSquare Area: " << Sous.Area();



	cout << "\n\n";

    return 0;

}