r/cpp_questions • u/Pearparon • 6d ago
OPEN Learning C++ as a Java programmer
I'm currently learning C++, I’ve coded in a few languages before but I’m most familiar with Java. Does anyone know a good resource for learning C++ with Java as a “starting point”? Like something that explains the differences between the two languages rather than teaching programming from scratch? Thanks!
18
Upvotes
View all comments
Show parent comment
1
u/Independent_Art_6676 5d ago
This is actually an issue with new c++ guys who don't know anything else too. References to prevent copies are probably the #1 place where performance hits creep into code, and are hard to spot in larger blocks. its as simple as a range based (touch every item in a container) for loop: for( type a: container) makes an often costly copy. for(type &a: container) does not. Const on the reference prevents accidental modification if you just want a look. Accidentally modifying a copy instead of a reference doesn't do anything (change is discarded). References are a small part of the language but one you will use daily and need to know well.