VOOZH about

URL: https://www.geeksforgeeks.org/cpp/shape-calculator-in-cpp/

⇱ Shape Calculator in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Shape Calculator in C++

Last Updated : 20 Jun, 2025

Shape Calculator is a console-based C++ application that demonstrates advanced OOP concepts through a system of shapes (e.g., Circle, Rectangle, Triangle, Square, Ellipse).

Features

Our Shape Calculator provides the following features:

  • Create different shapes at runtime (Circle, Rectangle, Square, Triangle, Ellipse)
  • Display area and perimeter
  • Compare two shapes by area
  • Menu-driven dashboard

Project Requirements

The following C++ concepts are required:

  • Classes, Objects, Inheritance
  • Access Specifiers, Constructors, Destructors
  • Virtual Functions, Method Overriding
  • Operator Overloading
  • Dynamic Memory Allocation

You’ll need a working C++ environment that consists of compiler like g++, clang++, or IDE like Code::Blocks, Visual Studio Code.

Implementation

Let’s break the implementation into steps:

STEP 1: Base Shape Class

We define a Shape class with virtual functions for area, perimeter, and displaying info.

STEP 2: Derived Shape Classes

Creating the derived class from the above base class shape:

STEP 3: Input and Dashboard

This dashboard provides interactive access to the program for creating different shapes depending on the choice of the user.

STEP 4: Main Function

The main function from where everything starts:

Execution

Combining all the above components, we get the executable source code:

On executing this code, we get the following output:


Comment
Article Tags: