0

I have a void operator+ and operator+=
How do I overlap them. I know that if I copy the same code in both functions it will work. I am more curious is there a shorter way without needing to copy the entire code?

Adin Sijamija
  • 695
  • 2
  • 7
  • 19

1 Answers1

0

You can implement one and call that from another, I mean you don't really need to duplicate the code, remember that

c += 20;

is the same as

c = c + 20;

so your + operator should instead of duplicate the code, wisely call the overloaded += operator

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97