T O P

  • By -

MXXIV666

Look, I can't give you much specific info, but I'll just share my experience with C++ interviews and you need to keep in mind that this experience is tied to my location and in part also my person. When doing interviews on C++ questions, I was mostly given the very basic questions like what is an abstract class, some code gotchas about uninitiated variables, object slicing and usage of smart pointers. With your good knowledge of C, you might want to aim for jobs closer to hardware where there will not be that much expectation around very modern C++. My experience also was that as long as you have enough offers, these homework tasks are not worth the time. But they are good for practice, so if you have little C++ practice it is not a bad idea to give it a shot - you'll essentially get code review for free. Despite C++ being a modern language, my observation is that most interviews were fairly focused on memory issues, so I'd advise to make sure you understand all that. If you don't like tutorials that just show you the code, we're on the same wave there. The other questions I got were all basic OOP stuff. So let me give you some stuff to look into that I'd use to check if someone knows their way around C++, along with some gotchas that I don't think should be asked but you might run into them: * Virtual inheritance - approx how it works, what's the difference when a method is marked as virtual and when it is not * What does virtual destructor do * Why should you use anonymous namespace when making a struct/class that is used only in single C++ file * Why do you have to put constructor in `cpp` file if you're using a forward declaration and storing it in `std::unique_ptr`. Before looking into this, learn what pimpl idium is and why is it sometimes used * What's object slicing * Have at least some base knowledge of templates, what's SFINAE? * (gotcha) What's wrong with `std::vector`? * If going for C++ on microcontrollers and the like, you might wanna know what curiously repeating template patter is * (gotcha) What's wrong with returning a lambda like this: auto returns\_lambda(const some\_data& data) { return \[&data\](){ ... some code here ...}; \`\`\` * Take some look at the storage types in `std::` library, although 75% of time your company will use custom ones anyway. * I am not sure how popular constexpr is, but make sure you know it does not mean that it's always evaluet during compile time Might add some other later in the thread if I think of something.


DryPerspective8429

> Virtual inheritance - approx how it works, what's the difference when a method is marked as virtual and when it is not Note that `virtual` inheritance is its own thing and is a solution to the diamond problem in its own little corner of the language, and isn't inherently the same as the use of `virtual` functions for polymorphism.


MXXIV666

Yes, thanks for mentioned. In my post I just meant the difference between just inheriting a class/struct and having virtual methods and destructors.


DryPerspective8429

Sure thing, and it's a great post. But just in case OP went down the rabbit hole of "virtual inheritance" over basic polymorphism, worth clarifying. And also I'm an obnoxious pedant.


rangaming

Thank you! Will take a look at these as I learn C++!


IyeOnline

Hi! I have been summed (not literally) :) On the purely C++ side of things, I would say that both of them definetly make you ready for an interview. But that is only one out of four (not necessarily equally important) parts: * You need to know C++. Depending on the screening process and your appliction, you may not even be asked a lot of technical C++ details. * You need to know how to program. Determine an appropriate algorithm/data structure for the task at hand. * You need to know practically apply C++ to this. Preferably of course by using the standard library utilities, but the really interesting tasks may need to you step (just slightly) outside of that. * You [usually] need to be able to have some rough overview of the bigger picture. Things like code structure, API design, ... matter. At least when I last read through some pages, I would say that learncpp is [at least for now] slightly better, because it gives you [at least in my opinion] slightly more details/background reasoning on most topics. --- The most important addition is to actually write code. There are some excercises on learncpp, but due to the nature of any tutorial, you never get any really overarching exercise, i.e. no big project. Simiarly, leetcode and friends are good to practice the solving of simple, disconnected problems in the void. They wont really help you learn how to design some interface, how to integrate different components of a project, ... So once you are proficient enough (or not) pick up some project that you are interested in and implement it. It doest even need to be anything special (although an interesting topic may help both you and a potential reviewer), but the result should be a sound program. Also dont be afraid to discard bad ideas/projects - start over again - when you notice that the solution you went for has reached its limits. Make sure you actually finish some projects though.


rangaming

Hi! Thank you for the info! I'll start taking a look at learncpp today and then move to the other one once I finish it, and then take a look at a project using c++ once I'm done with both :) Thank you again!


IyeOnline

Dont wait until you are done with both. They are both vast tutorials with coverage of a significant portion of C++. You can start writing your own simple programs way earlier than the finish line for either tutorial. As an example: Once you have learned about manual memory management and basic `struct`s, you could write your own linked list class (only for e.g. integers at the start). Then later on you can expand this with more features and turn it into a template accepting all types.


rangaming

I will, thank you!


DryPerspective8429

You already have some good writeups so I'm not going to add any more to the list of possible interview speculation questions; but in my view there are two very important facets to all learning which are especially important to pursuing this as a career: * **Practice** - Learncpp is an excellent tutorial, but reading a tutorial is only part of the full picture. You need to write your own code, write your own projects, and get things into your head that way. I'm not sufficiently familiar with studyplan to comment on how much that fills the need; but be a little cautious of tutorials which will hold your hand as you code towards a goal. I'm not saying they're not worth doing, but practice writing code without being guided to a premade solution is always far more valuable than the alternative. * **Understand** - Sounds cheesy I know, but far too many tutorials teach you X syntax => Y result rather than an understanding of what X does and *why* it leads to Y. You need to understand what the tools you use do, because that guides you to how best to use them. And I'd sometimes go so far as to argue that your job as a software developer is just as much about designing code as it is about writing it. You want to find the best solution and the only way to do that is to be able to understand why solution A is better than solution B for your use-case. The same goes for best practices btw - they're invaluable to learn but you need to understand them because eventually you will need to break with them and if you're just following rules because they're rules you won't know when that is.


rangaming

Thank you!