0

How on Earth do you overload operators in C++?

I simply don't understand operator overloading, and I need it for Part 2 of the C++ course's code project. Could anyone explain it?

3rd Jan 2025, 12:24 PM
MattMad
MattMad - avatar
5 odpowiedzi
0
before understanding operator overloading, you first need to understand the concept of overloading. So do you know what exactly overloading is?
3rd Jan 2025, 4:06 PM
Alhaaz
Alhaaz - avatar
0
That wasn't explained in the lesson about it.
3rd Jan 2025, 6:35 PM
MattMad
MattMad - avatar
0
MattMad, in introduction to C++, they explain operator overloading in the best way possible, firstly checkout this and if you face any problem so feel free to ask for help from me or other fellow coders https://www.sololearn.com/learn/courses/c-plus-plus-introduction
4th Jan 2025, 5:32 AM
Alhaaz
Alhaaz - avatar
0
Alhaaz I was referring to the one in the C++ intermediate — and I just revised the lesson on overloading in the C++ Introduction course
4th Jan 2025, 1:42 PM
MattMad
MattMad - avatar
0
Overloading needed when we need to do something with non basic data types. For example your class contains ints chars or any other variables(members), than if you want to add data to object of your class with +/- operator they should be determined for your class to do right things with right members of class. Or if you use + operator to sum two objects of one class, program should know how that two objects summs - what members will change. For example no one of two objects changes but console outputs some message.
4th Jan 2025, 8:45 PM
Сергей Лансков
Сергей Лансков - avatar