Is Jamie King's Approach to Operator Overloading in C++ the Best Practice?

  • Thread starter Thread starter yungman
  • Start date Start date
  • Tags Tags
    Operator
AI Thread Summary
Jamie King's approach to operator overloading in C++ emphasizes clarity by explicitly calling operator functions, which some find more descriptive than conventional methods. However, this approach sacrifices the inherent invisibility and elegance of operator overloading, which allows for more natural mathematical expressions. The discussion also highlights the importance of understanding modern C++ features, such as compound assignment and friend functions, which enhance code efficiency and readability. Some participants express a preference for traditional coding styles, arguing that simplicity and familiarity are more beneficial than adopting newer, more complex practices. Ultimately, the conversation underscores the balance between elegance and practicality in programming.
  • #51
Several other languages share most of the syntax of C and C++. Those languages include Java and C#, both of which are in my opinion significantly easier to master than C++. As far as I am aware, the only real reason to learn C++ these days is if you want to do Windows or Intel-instruction-set coding "close to the metal" or deep within the operation system. The virtual machine that C# runs on, its very smart compiler, combined with fast hardware these days, will do almost any number crunching that C++ will do, and will do it with less likelihood of a memory leak or a segmentation fault, which are nearly impossible to cause with the newer languages.
 
  • Like
Likes yungman
Technology news on Phys.org
  • #52
harborsparrow said:
Several other languages share most of the syntax of C and C++. Those languages include Java and C#, both of which are in my opinion significantly easier to master than C++. As far as I am aware, the only real reason to learn C++ these days is if you want to do Windows or Intel-instruction-set coding "close to the metal" or deep within the operation system. The virtual machine that C# runs on, its very smart compiler, combined with fast hardware these days, will do almost any number crunching that C++ will do, and will do it with less likelihood of a memory leak or a segmentation fault, which are nearly impossible to cause with the newer languages.
I am already knee deep in C++, it would be a shame to drop it at this point. My biggest problem with learning C++ is the terms they use, I had a hell of a time following all the names and terms like objects, instance, arguments, instantiation, attributes, methods, dereferencing, streaming...Took me a long time to follow all these. Do other languages use the same terms? If so, that would be a big head start for me. Do other languages follow the same logic like C++, just different syntax?

The other language I would seriously consider is Python.

Thanks
 
  • #53
Those languages are all object oriented and they do use the same words. You will find that learning any 2nd language to be easier than the first. And a third even easier. The libraries will be the main learning curve, and many things including strings and graphics are easier. Python is more different but popular because it is easy to get started in. I like to learn a new language by rewriting some small program whose design and logic I already know. It is a good way to decide what each language is good at.
 
Last edited:
  • Like
Likes yungman
  • #54
harborsparrow said:
Those languages are all object oriented and they do use the same words. You will find that learning any 2nd language to be easier than the first. And a third even easier. The libraries will be the main learning curve, and many things including strings and graphics are easier. Python is more different but popular because it is easy to get started in. I like to learn a new language by rewriting some small program whose design and logic I already know. It is a good way to decide what each language is good at.
Thanks for the info. I am on the chapter of operator overloading in class, one more chapter on Inheritance and Polymorphism and I finish the whole book by Gaddis. What do you think is a good stopping point of C++ and venture out for other things or language? I kind of want to study the chapter on Library and template in his other book, but I am open for suggestions. I hate to start something and stop in the middle. took me a while to decide to take on C++, I want to at least study to a good point to stop. I am kind of regret not choosing Python at the time.

I don't know where to draw the line as I can keep studying C++ forever! Just want to know what is a good place to stop and move on to other things. One thing that bugs me is that I almost finish the whole book and I am still working in cmd window. When am I going to get pass that and actually doing something?

Does Python have pointers, vectors, structures, classes, files etc. like C++ that I can relate to?

Thanks
 

Similar threads

Replies
23
Views
2K
Replies
5
Views
3K
Replies
4
Views
2K
Back
Top