I understand the concept but i don't know when to use and what my teacher expects when he says overload certain operators.
lotrsimp12345 37 Posting Pro in Training
Recommended Answers
Jump to Post— Ancient Dragon 5,243Normally overload operators so that you can do mathematical or other operations with c++ classes. for example:
cout << MyClass;assuming MyClass is an instance of some c++ class and you want that class to print the value of its class variables to the screen. Or you might want to …
Jump to Post— minas1 1You overload an operator when it makes sense to do so.
Say that you create a custom string class MyString.
It makes sense to overload the + operator, but not the ~.
All 7 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
minas1 1 Junior Poster in Training
Dave Sinkula 2,398 long time no c Team Colleague
lotrsimp12345 37 Posting Pro in Training
minas1 1 Junior Poster in Training
lotrsimp12345 37 Posting Pro in Training
lotrsimp12345 37 Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.