How to Overload the (+) Plus Operator in C++? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In C++, operator overloading is a feature of the OOPs concept that allows you to redefine the behavior for different operators when they are used with objects of user-defined classes. The plus operator (+) is a binary operator generally used for addition. In this article, we will learn how to overload the (+) plus operator in C++ for a user-defined class. Overloading the Plus(+) Operator in C++ To overload the plus operator, we have to create an operator+ function inside our class and define its behavior inside this function's body. The following syntax shows how to do it: myClass operator+ (const myClass& obj) const { // new behaviour }C++ Program to Overload the Plus(+) Operator for a Class C++ // C++ program to demonstrate operator overloading of plus // operator #include <iostream> using namespace std; // Class definition class MyClass { private: int value; public: // Constructors MyClass(): value(0){} MyClass(int val): value(val){} // Overloaded operator + MyClass operator+(const MyClass& other) const { MyClass result; result.value = this->value + other.value; return result; } // Getter method int getValue() const { return value; } }; int main() { // Create objects MyClass obj1(5); MyClass obj2(10); // Use overloaded operator + MyClass result = obj1 + obj2; // Output result cout << "Result: " << result.getValue() << endl; return 0; } OutputResult: 15 To know more about operator overloading, refer to the article - Operator Overloading in C++ Comment More info A anuragvbj79 Follow Improve Article Tags : C++ Programs C++ cpp-operator CPP-OOPs CPP Examples +1 More Explore C++ BasicsIntroduction to C++ Programming Language3 min readData Types in C++7 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++5 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++11 min readFile Handling through C++ Classes8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++10 min readPolymorphism in C++5 min readEncapsulation in C++4 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL3 min readIterators in C++ STL10 min readC++ STL Algorithm Library2 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples7 min read Like