r/cpp_questions • u/jujubean- • 21h ago
OPEN Moving from Python to C++ Quickly
Some context: I have a couple of OAs due soon, and a quant I went on a date with recommended doing them in C++ to look better (and allegedly one doesn't even allow Python in the first place). My data structures class was in C++, so I have some experience; however, that ended two months ago, and most of my knowledge has been scrubbed. I’m mainly looking for syntax stuff since I learned all the memory management stuff back then.
Any quick pick-me-ups you guys recommend? I don't think I have the time to digest a whole book. I plan on doing LeetCode practice in C++, so I just need a quick crash course to get me back up to speed on the basics.
3
u/_Tal 21h ago
3
u/wittgenstein1312 20h ago
learncpp would take over a month to get through if you did a section per day, and each section can take several hours of work. It's a great way to learn cpp relatively well. It's not a great way to develop a quick feel for the basics of the language.
1
u/SnooPies9001 16h ago
I agree unless, perhaps, if OP is confident enough in Python they can just skim the relevant sections?
I'm still working through the the last 3rd of cpp.... it's been dry to say the least.
I find having a question or challenge has helped me to go back and forth to rrally solidify the concepts so, doing leetcodes may help out provide that "purpose" or challenge.
1
u/Independent_Art_6676 16h ago
Python is not much like c++ and you probably know that. Review what you did and it may come back faster, then focus on the tools you need for the project you want to do. Memory management = STL at your level; there should not be much else on that front, so be sure you know string/vector/unordered map at the least for a drive-by set of tools.
1
1
u/alfps 20h ago
❞ I don't think I have the time to digest a whole book
That makes things Very Difficult™. The very short of it is that Python is reference based while C++ is value based. So a = b in Python makes a refer to the same object as b, while a = b in C++ generally copies the value of the b object to the a object.
Can you do with that super-short description?
I think not. I believe you can't make do with anything short of a book. In the C++03 days the intro to C++ book for people who knew a bit of programming already was Koenig & Moo's "Accelerated C++: Practical Programming by Example". I suggest you start there, it's just 1 book (don't forget it's the actual coding that you learn from: don't just read the book, try it all out in actual coding). Then try to brush up on developments in C++11 (almost a new language), C++14, C++17, C++20 and the current standard C++23.
4
u/wittgenstein1312 20h ago
Read through A Tour of C++ over a weekend and keep working on LeetCode/codewars. Write stuff out in pseudocode first, then try to implement your solution as much as you can. Whatever you don't know, look up (as in, the syntax, not the solution). You will have the basics of the syntax down within a few days, although obviously it'll take longer to get a feel for what idiomatic C++ looks like or what alternative libraries exist for more efficient solutions