Already overloaded operators <<,>>,= etc are used many times.
An example that i was thinking of is when we add strings say :
string name = string(“munish”) + “kumar”;
the + operator is overloaded in the string class.
but when we add numbers like 1 + 2( doesn’t seem like an overloaded operator call)
I was just wondering how does it happens does the compiler does a binary additon.
I don’t need to worry about it much though if the compiler does it so, just a matter of curiosity for me.
Primitive types don’t implement
operator+which is actually a function with a weird name. Addition for Primitive type is carried out by CPU instruction such as :You implement
operator+for user-defined types, and compiler generates lots of CPU instructions to carry out the task which you write inoperator+.