Posts

Showing posts with the label overloading in cpp

Operator Overloading in C++ | Operator Overloading Explained With Real Life Examples

Image
 Operator Overloading in C++ What is operator overloading? Operator overloading means overloading an operator. 😑BRUH... I know you don't understand. Let me put it in a simple manner, suppose if I will say make a faulty calculator where "+"  will do subtraction, "-" will do division, "*" will do addition, "/" will do subtraction. So you will say what are you saying Dhruv.  Hmm, but I am not saying wrong it is possible by operator overloading. Let's understand by your favorite example - YOUR WEDDING EXAMPLE 😍🤣( Now don't start thinking about your bride just understand this concept you boiss) So Suppose when your bride was of 8-10 years then what she says that her father's house is her, her father's car is her car. But when her wedding happed then everything will change like the person is the same but now your bride will say Your car is her car also, your home is her home also. So here the person is the same but ownership is c...

Overloading Of Constructor In C++ | Constructor Overloading Explained With Real Life Examples

 Overloading Of Constructor In C++  What is constructor overloading? As you know what is a constructor  and also what is function overloading . So you know constructors are special class methods which is basically a function which runs at the starting of class always. So as you know how to overload a function then the constructor is also a function so you can overload a constructor as same as function overloading. #include   < iostream > using   namespace   std ; class   calculator {      public :      calculator ( int   a ,   int   b )  //constructor with 2 int type parameter      {          cout << " I AM CONSTRUCTOR  " << a + b << endl ;      }      calculator ( int   a ,   int   b ,   int   c )  //c...

Function Overloading In C++ | Function Overloading Explained With Real Life Examples | Function Overloading In OOPs

Image
 Function Overloading In C++  What is function overloading? Function overloading means creating duplicates of the same function but it will be different from that function. WHAT ??. I know you don't understand. So let me explain this concept by a real-life example. So think about your mother, your mother is a woman but she plays many roles like sometimes she is your mother, sometimes she plays the role of wife, sometimes she plays the role of daughter, etc. So your mom is overloading to the different roles she overloads different roles every time. So same function overloading means to overload properties of different functions. And here is the official definition of function overloading -  Function overloading  is a feature in C++ where two or more  functions  can have the same name but different parameters. When a  function  name is  overloaded  with different jobs it is called  Function Overloading . Here in C++ Function overloadi...