#include <iostream> using namespace std; class Displacement { private: int meters; public: // required constructors Displacement() { meters = 0; } Displacement(int m) { meters=m; } // overload function call Displacement operator()(int a, int b, int c) { Displacement D; D.meters = a+b+c; return D; } // it show the displacement void show_displacement() { cout << meters << " Meters " << endl; } }; int main() { Displacement D1(100), D2; cout << "D1 Displacement : "; D1.show_displacement(); D2 = D1(200, 200, 200); // invoke operator() overloading method cout << "D2 Displacement:"; D2.show_displacement(); return 0; }Output D1 Displacement: 100 Meters D2 Displacement: 600 Meters
Related Blogs

Top 10 No-Code Platforms to Build a Product
Building a product isn’t as daunting as it seems, especially with the technologies available …

What is SQL? A Detailed Guide for Beginners
A database is a well-structured collection of data, and it stores and manipulates data electronical…

Top 10 Real-World Python Applications That You Should Know
We live in a world where people and businesses rely highly on software applications to accomplish a…
Leave a Comment on this Post