I'm a Math and Computer Science undergraduate looking to learn C++ in just two months for a research internship. My background includes solid skills in C, particularly with pointers and memory management, and I'm currently studying Java, which has given me a grasp of OOP concepts. However, I have no prior experience with C++. My project involves implementing k-order Dynamic Bayesian Networks (k-TBNs) in a large existing scientific C++ library, translating complex algebra from Python into optimized C++ code. I need suggestions on how to learn effectively and what key C++ features to focus on given my background, specifically for mathematical computations and the use of C++20. What concise resources would you recommend?
3 Answers
Your background gives you a significant edge, and I think you’ll adapt well. C++ really combines the best of C and Java, with some added complexity. Focus first on understanding smart pointers, like unique_ptr and shared_ptr. Translating your Python code line by line while referencing cppreference will also help you learn the ropes without diving into long tutorials. For math functions, consider using the Eigen library—it simplifies a lot of the complex stuff you’ll be working on.
Eigen is a fantastic library for linear algebra. You'll find it very handy.
It sounds like you have a tough road ahead, but you'll be fine! C++ is generally C with some OOP features mixed in, so it should feel familiar. Start with mastering the basics: smart pointers, vectors, and arrays, then worry about templates and lambdas later. Also, get comfortable with the STL and iterators; they’ll really help you streamline your coding process.
Understanding the STL is crucial; it’s super efficient for handling collections of data!
Absolutely! Once you’ve got the basics down, templates can really elevate your work.
With your background in C and Java, you're in a great spot to tackle C++. Focus on templates for your math work—they'll allow you to write more general algorithms that handle various numeric types efficiently. I recommend starting with "A Tour of C++" by Bjarne Stroustrup; it's straight to the point without any fluff. Additionally, cppreference.com will be an essential resource for syntax. Since you're dealing with heavy math, definitely prioritize learning move semantics and rvalue references to avoid unnecessary copying when working with large matrices.
Totally agree! Templates will be super helpful, especially when dealing with math-heavy algorithms.
Don't forget about smart pointers! They really simplify memory management.

Smart pointers are life-savers! They definitely make handling memory way less of a headache.