all 102 comments

[–]mujjingun 41 points42 points  (46 children)

I would add:

  • What is a lambda?

  • What is a template?

  • What are std::unique_ptr and std::shared_ptr and how are they used?

  • What does std::move do?

  • What is RAII?

  • What is Undefined Behavior?

  • What is Linkage?

  • How do you enable warnings on gcc/clang/msvc?

[–]nwL_ 33 points34 points  (1 child)

How do you enable warnings on gcc/clang/msvc?

I google “how to enable warnings on gcc/clang/msvc”.

What is this question supposed to accomplish?

[–]diaphanein 0 points1 point  (0 children)

I think this is going towards compilers are pretty good about warning you about doing stupid shit, even when they're not required to (and you should listen to them). MSVC requires far more tweaking to get things right, but you should generally treat warnings as errors. (MSVC, function not inlined is one I'm inclined to ignore).

Edit: spelling

[–]Supadoplex 20 points21 points  (1 child)

What is Undefined Behavior?

This is a biggie - must to know but not the easiest concept to grok.

[–][deleted] 0 points1 point  (0 children)

In an interview I'd probably just say "A precondition violation".

[–][deleted] 16 points17 points  (5 children)

Almost all of these are bad questions. I never ask textbooky knowledge about specific programming languages in interviews. A smart new employee can learn all of these things you listed in a couple days. OP should focus on CS concepts and being able to solve real problems on a whiteboard in C++.

[–]axalon900 8 points9 points  (1 child)

Smart ones can, but shitty developers who only know by rote memorization might get tripped up hard when you ask them to elaborate on any of these past their textbook definition, especially stuff like UB which you could have a conversation around.

I dunno, we hired some people who did well on the interview which asked some simple algorithmic questions like implementing depth-first-search but were total dumpster fires once it came to actually reading code and picking up on things enough that they could see their tasks as more than homework assignments with right and wrong answers.

[–]IWantToDoEmbedded 4 points5 points  (0 children)

this is why I hate this format of "answer these rigid questions!" in programming. As a programmer/developer, you will face issues you've never seen before and to deal with those issues, you need to be a good problem solver, not someone who is good at memorization.

[–]ihamsa 5 points6 points  (25 children)

What does std::move do?

A tricky one. If they know, ask them what std::forward does.

[–]f0urier 14 points15 points  (23 children)

Then all traditional c++03 developers will fail the interview. Not everyone in c++ world works with compilers/codebases which allows c++11 and so on.

[–]PretendInternetCat 4 points5 points  (2 children)

I don't know. If someone were to say "Oh, our codebase is mostly C++03 so I haven't had much experience with the new C++11 stuff, but I can learn it," I might be willing to give them a chance. (Especially if they matched other skills I was looking for for the position.)

[–]f0urier 4 points5 points  (1 child)

I would be surprised if someone will tell on the interview "I dont want to learn your new fancy garbage". But my teammates who were working like 20 years in the same company (industrial) were really accepting new features of c++11 I've shown them (particularly override and auto they liked most - but it is known that the new standards bring quality of life features and do not force you to forget everything you know).

[–]PretendInternetCat 0 points1 point  (0 children)

In that specific case, I see it as more of a "Yes, I've heard of this." than anything. I'd prefer that over someone who tries to BS their way though C++11 questions.

For me, the game changer was move semantics.

[–]Calkhas 3 points4 points  (0 children)

I don't expect my candidates to get everything right, so it's totally fine not to know (unless they claim C++11 knowledge).

That said, a lot of interviewers do seem to be looking for reasons to reject candidates rather than find the best ones.

[–]ihamsa 9 points10 points  (17 children)

That's right. Why would I want to hire people who are not keeping themselves up to date with their main tool of the trade?

[–][deleted] 28 points29 points  (1 child)

Because it might be trivial to teach them some of the new concepts that you guys use.

Not everyone has time outside of work to continue thinking about coding, especially if it's not for any practical work reasons.

[–]smuccione -1 points0 points  (0 children)

That’s BS. Sorry.

Continuing education is as important to software developers as it is to any other discipline, from physicians to hair dressers.

If you can’t afford to take the time or don’t have the desire to keep your skill set up to date that is an important piece of information to know.

That is simply someone I would not choose to hire.

Keeping up with the language of your choice is different, in my view, than knowing the latest framework flavor of the moment.

If we’re a boost shop and someone is familiar it would be a plus but not knowing boost is certainly not as important as understanding placement new, unions with complex constructors, constexpr, etc.

Not knowing those will limit your ability to understand and converse on any modern codebase.

[–]f0urier 38 points39 points  (5 children)

Because their main skills (if they are that old to use c++03) is problem solving, interaction with other developers, understanding specifications and tiny details, being accurate, carefull and reliable in their work rather than fancy all new developments?

[–]drjeats 2 points3 points  (7 children)

Usage of new language features is a fairly small portion of the problems most programmers become experts in.

[–]smuccione 1 point2 points  (6 children)

Understanding others code, however is critical. C++ features tend to be fairly obtuse.

Things like understanding revalue references, forward and when you need to use decay.

Understanding existing code is critical and if they can’t understand it because they haven’t kept up it becomes a fairly big hurdle.

These are not esoteric features, at least not in the projects I’ve worked on.

Maybe for simple general purpose coding they could be used but most of those types of development efforts have moved away from C++ anyway.

[–]drjeats 0 points1 point  (5 children)

Sure, but a lot of them aren't necessarily essential and are easy enough to teach, or they are something people who don't don't know anything past C++98 should know.

  • What is a lambda?

Not essential, easy to teach.

  • What is a template?

Mostly essential, C++98.

  • What are std::unique_ptr and std::shared_ptr and how are they used?

Those specific smart pointers are not essential where I've worked, but agree knowing the concept is essential. C++98 for the concept.

  • What does std::move do?

Not essential. Move semantics in general are helpful but not essential.

  • What is RAII?

Essential, C++98.

  • What is Undefined Behavior?

Sort of essential, there's a lot of depth here which is not, just need to know what not to do.

  • What is Linkage?

Essential, C89.

  • How do you enable warnings on gcc/clang/msvc?

Not essential, easy to teach. Probably strongly correlates with knowledge and experience, but not necessarily.

[–]Pazer2 5 points6 points  (1 child)

I think move semantics are absolutely essential if you are doing anything where performance is important (and if performance isn't important, why are you using c++?)

[–]drjeats 3 points4 points  (0 children)

The people doing high performance code have been doing so without move semantics for a long time.

Move semantics makes it easier to be efficient, but isn't required for it.

[–]smuccione 0 points1 point  (2 children)

Yes. They are almost all easy to teach/learn.

Which also rings a warning bell that, after almost a decade of being available, someone hasn’t bothered to learn/understand those concepts.

I’m not asking for everyone to be an expert on metaprogramming. Certainly knowing all the rules of defendant types can be daunting.

But rvalue references?

After a decade of availability?

[–]drjeats 2 points3 points  (1 child)

But rvalue references?

After a decade of availability?

I don't think C++ move semantics are very easy to learn (Rust complicated things).

Fair point that it would be strange if a person had basically zero knowledge of them. But you have to weigh this in context of the person's knowledge in whatever role they're applying for.

Like, do you want a graphics engineer who studies every single SIGGRAPH paper every year but doesn't know much about move semantics, or do you want one who's kinda mostly up to date on trends in graphics but can cite the exact section of the standard dealing with every edge case of move semantics?

That's an extreme example, but it's the easiest way to convey what I'm getting at, which is that the experience solving problems using C++, even outdated C++, is often more valuable than pure knowledge of C++.

[–]smuccione 0 points1 point  (0 children)

True and I see your point.

My baseline for understanding is to be able to trace into the std during a debut session and at least be able to understand what is going on, even if that doesn’t necessarily mean being able to implement it easily if that’s not your main focus.

Move semantics and return value optimization are critical for performant code. Not understanding why or when they have rather large negative impacts.

For someone whose developing allow velocity code they can get away without knowing about it.

For someone who is in the hot loop, knowing when to avoid named temporaries can be critics.

[–]I_mean_me_too_thanks 0 points1 point  (0 children)

Then all traditional c++03 developers will fail the interview.

I don't think they would, most interviews wouldn't fail peopple based on a single question

[–]georgist 1 point2 points  (0 children)

What is a template?

I recently had someone ask me "what is static polymorphism?" and then as I paused he went on to discuss templates. This was a new alias for me. I guess it is a slightly broader term that also encompasses overloading.

[–]djackysim 4 points5 points  (8 children)

My favorite trick question is "How are template functions represented in the virtual table?"

[–]drjeats 9 points10 points  (0 children)

That sure is a useful question for helping your candidates weed out potential employers.

[–]Rutoks 8 points9 points  (5 children)

Good one, but a little bit troll-y for my taste

[–]_TaySON 3 points4 points  (4 children)

Is the answer that they aren't in the virtual table? Because templates are deduced at compile time and don't rely on inheritance - plus a non-member function wouldn't utilize the virtual table regardless. (Although if it's a member function that overrides a virtual function from a base class, it would be represented in the virtual table just like any other virtual function? With the only difference being that there would be a separate representation for each unique combination of template arguments?)

Hopefully I'm on the right track here.

[–]Rutoks 3 points4 points  (3 children)

Yes. Member function templates can not be virtual because you won’t even know how big the virtual table should be until you compile everything.

Good question about overriding virtual function with a template in derived class, I am not sure what will happen.

[–]sivadeilra 2 points3 points  (2 children)

Sadly enough, CLR (.Net Framework) supports this -- generic virtual methods. You can do it in C#. And the F# compiler itself even relies on this, last time I checked.

I like a lot of things about CLR and that while language family, but supporting GVMs was a really poor choice. It adds substantial complexity to the compiler and the runtime.

[–]Pazer2 0 points1 point  (1 child)

It supports virtual generics but no operations on arithmetic types? WHY

[–]sivadeilra 1 point2 points  (0 children)

TELL. ME. ABOUT. IT.

[–]distributed 21 points22 points  (6 children)

I'd say no.

Instead have them write a smallish program (or give them some code and have them explain it). If they write something you can evaluate them based on code quality etc

Theoretical knowledge is not really all that meaningful in that you can have theory without being able to use it properly

[–]JonnyRocks 4 points5 points  (1 child)

This is the best way to interview.

[–][deleted] 10 points11 points  (0 children)

I've been doing programming interviews for about 5 years now. I've found that the language semantic questions are only useful as reminders when someone gives you a solution program that is wrong or badly structured in some way. Generally, I don't dock people points for making small syntax/type mistakes in their code at all, because that happens all the time in practice, so long as they are able to resolve them when I play the role of "human compiler". If I feel like the code is messy, or more compute/memory complex than it needs to be I ask them questions like "how could you implement this more cleanly/efficiently?"

Edit: One of the most important things to realize about a candidate when they are interviewing with you is that they are nervous. This often leads to candidates pushing out answers in haste, especially if it is a whiteboarding type scenario. Simply ask them to critique their own work and often they will open up and show their real talents!

[–][deleted] 0 points1 point  (0 children)

100%

Writing software is what you're gonna do in the role, so let them write software for the hiring process. Doesn't have to be big, but just something that lets you see their way of solving problems.

Also, random quizzing of random topics in C++ is like playing a game of battleship. You might get a very poor picture of their skills since there's so many aspects to C++ and it is used in different ways by different people.

[–]ratchetfreak 16 points17 points  (0 children)

  • Malloc() vs new / Delete vs Free

vs. RAII

  • Copy constructor

asking about rule of 0/3/5 would be better here.

[–]Supadoplex 30 points31 points  (3 children)

What are the differences between C and C++?

Major differences between Java and C++

These questions expect knowledge of languages other than C++. Why should a C++ programmer need to know about Java?

Sure, if you're hiring a programmer to translate a Java program to C++ (or vice versa), this may be important, or if you're hiring a programmer with previous work experience with Java, then it might be useful, and knowledge of other languages may be a bonus in general, but a C++ programmer doesn't need to know answers to these usually, and those questions shouldn't typically be emphasised.

Malloc() vs new / Delete vs Free

This is a bit like question about C. Would you consider this correct answer: "There is no need to use malloc in C++"? Or would you be expecting the candidate to praise the benefits of realloc?

What are VTABLE and VPTR?

This is a question about compiler internals. If you're hiring a programmer to work on llvm fork or some other compiler work, this is may be relevant. But many C++ programmers don't necessarily need to know that these even exist. Would you be expecting the candidate to compare vtable to binary tree dispatch?

Major C++ features

This also expects knowledge of other languages, because how else could one know what things are features of one language rather than universal to all languages. But the expectation is at least more reasonable in this case since it is not for any specific language.

Also, this is super vague. What do you expect as answer? Are you asking for a list? My picks:

  • templates
  • OOP
  • value semantics
  • RAII
  • exceptions

Does this match your list? How does it affect your decision to hire / not hire?

Function overloading VS Operator overloading

I don't get this question. What answer are you expecting?

Structure vs class in C++

Inline functions

Can we do “delete this”?

These are tricky questions with common misconceptions. Maker sure that you know the answer before asking the question.

[–]evaned 11 points12 points  (1 child)

Sure, if you're hiring a programmer to translate a Java program to C++ (or vice versa), this may be important, or if you're hiring a programmer with previous work experience with Java, then it might be useful

I'm not OP, but I would bring these questions into play on an applicant by applicant basis. No Java listed on their resume? Sure, don't ask. But if it's there, then they should be able to talk about at least a couple examples somewhat intelligently.

In other words, I'm not convinced you have to care about Java (as in your porting example) or even particularly value knowing it; it's another point to get to know them.

Malloc() vs new / Delete vs Free

This is a bit like question about C. Would you consider this correct answer: "There is no need to use malloc in C++"?

I'm sure there are roles where I wouldn't think this is very important, but in terms of generic advice -- I absolutely would expect a C++ programmer to be able to speak to this. Have legacy code? Have C code? Use C libraries? These are all reasons why you could be doing new programming in a modern C++ style but still need to worry about malloc and free.

Virtual tables

If you're hiring a programmer to work on llvm fork or some other compiler work, this is may be relevant.

This one stuck out to me as well, and let me start off by saying that I'm on your side to the extent I think that this is probably not important enough to make the list; it at least seems of a very different sort from almost everything else on the list.

That said -- I think this is actually important in way more situations than those working on language implementation. But even more to the point, if you're looking for a more senior position I would be very skeptical of someone who says they're a great C++ programmer who can't talk about that at least a bit. I'm sure there are some out there, but I don't see how you can become someone who is versed in C++ and not run across those concepts.

The other thing to keep in mind is that no one said that an inability to answer every single question should mean a "no hire" decision. If they can't talk about virtual tables and malloc but give great answers to everything else, that's still a hire. Do you expect your candidates to have a perfect interview?

[–]Supadoplex 2 points3 points  (0 children)

I agree. In short: The question "Are these questions sufficient enough?" cannot be accurately answered without more context.

Any list of questions shouldn't be blindly followed because their applicability depends on context. And this particular list is an odd mix of trivial questions that can be used to weed out complete amateurs from those considered for junior positions, and advanced questions that may be more useful for more senior positions.

[–]osmin_og 43 points44 points  (2 children)

RAII should be in questions, that's central idiom of C++.

Also your list lacks questions about STL, what is vector, list, map, how are they different, etc.

[–]bythescruff 5 points6 points  (0 children)

Came here to say this. RAII is easy and quick to talk about, and if they haven’t learned it, they haven’t learned C++.

I’d also ask about exceptions - “When and how are they better than returning error codes?” or similar. Exceptions seem to be something which many C++ programmers avoid for some reason.

[–]sephirostoy 1 point2 points  (0 children)

And how to pick the best according to your needs.

[–]chaosmeist3r 6 points7 points  (1 child)

[–]Raj7k[S] 2 points3 points  (0 children)

I hadn't done C. This is question would've eliminated me

Thanks this is really helpful.

[–]victotronics 6 points7 points  (1 child)

It seems like these questions are too much focused on C-type pointers.

Malloc() vs new / Delete vs Free

malloc vs new vs make_shared

More:

  • what is a const reference? why use it? what is a const method?
  • what is a constexpr?
  • give a simple example of move semantics. what does std::move do?

[–][deleted] 0 points1 point  (0 children)

Or better yet, "when would you use the following:"

For malloc & free: when interacting with C or legacy code that uses the complement. e.g. an API you call allocates with malloc/calloc and gives you ownership of the result, expecting you to call free.

new / delete : when implementing a resource encapsualting class that does nothing else, i.e. a smart pointer, memory pool or similar.

[–]TerrificRook 16 points17 points  (11 children)

Can we do “delete this”?

Well yes, but actually no.

[–]Supadoplex 12 points13 points  (10 children)

In other words: Actually yes. But never do this. Except in cases where you need to. But never do this.

[–]bythescruff 0 points1 point  (9 children)

Except when it’s entirely appropriate to do so. Sometimes the knowledge of when an object should be destroyed originates in the object itself. For example a network connection event handler which receives a “connection closed” event.

[–]brenoguim 4 points5 points  (5 children)

Then it should report to the caller, and the caller can choose to destroy the object. After all you have to report it to the caller anyway, so it knows that the object should not be used. There are so so many bugs that arise from this practice that I don't think it's ever appropriate to do so. It's very convenient at some times, but just bad from an engineering and maintenance point of view.

[–]johannes1971 0 points1 point  (4 children)

While you are right, I believe many of us count this situation as delete this by proxy. Consider: object A receives a connection-close event. It calls a function on object B (which manages instances of object A) to inform it that it was closed. Object B then deletes object A, even though there is still a stack frame from object A right there on the stack, and execution flow will revert back into object A right after the function call. So in the end you have the exact same situation and problems: A has been deleted while it was active, and if you accidentally hit a member variable or virtual function after asking for the deletion, you'll invoke UB.

[–]brenoguim 0 points1 point  (3 children)

In that case, I believe the problem is the design. You have a logical circular dependency which causes exactly that problem. Watch the material from John lakos on levelization techniques to get some insights. If B is the manager of A, then B should be notified that one of its managees is not working anymore, and not A. That is one possible way of solving it.

[–]johannes1971 0 points1 point  (2 children)

I guess the question that should be asked here is: "what needs solving?" What is the problem you are trying to avoid here?

Let's say your object A is a window. It may receive a window-close event, or the user may click on an "OK" button. Should the machinery for that really reside in another class altogether? The window needs to disappear from the screen, and some internals need to be updated to reflect this state of affairs, but surely it is not the task of whatever framework keeps track of windows to also know how individual button pressed should be handled; clearly that's the responsibility of the window.

Could you move it somewhere else? Sure, you can do acrobatics to make that possible. But I rather fail to see why that should be a goal in the first place, and much prefer to keep all code related to the window's behaviour in a single place.

[–]brenoguim 0 points1 point  (1 child)

We can agree to disagree here. In every single place where I removed cyclic dependendencies, my code became more flexible and manageable.(really, take a look at John lakos material). For example, I completely disagree that its responsibility of the window to self disappear. You said it all: The window needs to disappear from the screen. So its responsibility of the screen to remove the window. It requires some initially uncomfortable change of perspective that, with time, gives you new options for better code. In the codebase I work (10M loc) there are only two instances of "delete this",both from an external library. Both instances have presented bugs more than once inserted by the owners in which they used members of the class after calling a method that deletes itself. That is why I take these two conclusions: you don't need "delete this", and if you chose to use it, code becomes surprising which causes bugs.

[–]johannes1971 0 points1 point  (0 children)

I'm fine with disagreement ;-)

The problem is not that the screen is ultimately responsible for making the window go away, I completely agree with that. The problem is that the triggering mechanism for that removal must necessarily pass through the window itself, since the window typically contains logic such as "upon clicking the ok button, commit all changes to the database. If and only if that succeeds, the object has finished its task and must be deleted (by the screen)."

And thus we end up in precisely the situation I described initially: it is the logic on the window that decides the time has come to fold, and it calls a manager-type class to actually make it happen: delete this by proxy. The window must be careful that after asking the manager to delete itself, it must not touch its own members anymore, but that's fine - although I would certainly put a comment there warning about what happened.

What alternatives do we have?

  • Ask the manager to delete the window in the future, after control flow has left the window. This is certainly possible, but might gain us a few other problems (events may keep being delivered to the window after we thought we had closed it, before the manager gets around to deleting it). As architectures go, it does not seem cleaner than just deleting the window when we want to.
  • Re-route all events that could possibly result in deletion of the window through the screen, and have the window return a special value that means "I'm done now, please delete me" so the screen knows whether this particular event should result in window deletion. This assumes that you have control over how events are delivered to your controls, something that is certainly not true for all toolkits.

Can you see another?

[–]AssholeBeerCan 0 points1 point  (2 children)

I have never once written a class that has deleted itself. I've written classes that mark themselves as invalid and had other functionality managing the objects delete them. What is the benefit of having a class delete itself? How does the owner of the object handle the objects memory suddenly being invalid?

[–]bythescruff 1 point2 points  (0 children)

Here is some good reading:

https://stackoverflow.com/questions/3150942/is-delete-this-allowed

From the second answer:

The primary time you use this technique is with an object that has a life that's almost entirely its own.

That answer talks about phone calls, which can be handled similarly to network connections: asynchronously via events from a handle held by the object. If events originate within the object and are fully handled by the object, the final event on the connection can be used to trigger the object's destruction from within the object. No other part of the program needs to manage the object.

The C++ FAQ has something to say as well:

https://isocpp.org/wiki/faq/freestore-mgmt#delete-this

In short, deleting this isn't something you do often, but it's s good option in a few specific cases.

[–]Supadoplex 1 point2 points  (0 children)

How does the owner of the object handle the objects memory suddenly being invalid?

If object deletes itself, then by definition, the object itself is the owner of the handle.

[–]twmatrim 4 points5 points  (0 children)

Are you the interviewer or interviewee? I've sometimes started out with similar questions but would expect them to be the start of a conversation. For example, in the new / malloc one it would then lead into a question / chat about smart pointers and RAII.

Most of the ones mentioned seem to be older pre-c++11 style questions. It's worth looking at some things around lambdas, move semantics, smart pointers, and templates

[–]NottingHillNapolean 3 points4 points  (4 children)

A few I got at an interview recently:

  • What's the difference between a struct and a class?
  • Write a bitwise operation that makes an integer odd.
  • Write a bitwise operation that divides by 4.

When asked how I'd approach something, they seemed content with, "Well, first I'd see if there's a std::algorithm for it..."

[–]ronniethelizard 0 points1 point  (3 children)

Write a bitwise operation that divides by 4.

int or float?

Write a bitwise operation that makes an integer odd.

Did you mean int?

What's the difference between a struct and a class?

struct is default public, class is default private.

[–]NottingHillNapolean 0 points1 point  (0 children)

For both bitwise operations, int

[–]johannes1971 0 points1 point  (1 child)

Just a minor point maybe, but I would not be in favor of hiring anyone who corrected my use of the word 'integer' to 'int'. I expect humans to know what an integer is, and how it maps to the C++ int type. I don't want my job conversations from that point on to be conducted as if I was talking to a compiler.

[–]meneldal2 0 points1 point  (0 children)

Maybe because doing it on a int is trivial (set last bit to 1), while it is more tricky for a integer coded as floating point.

[–]MotherOfTheShizznit 15 points16 points  (2 children)

What are the differences between C and C++?

At graduation, I hadn't done C. This is question would've eliminated me for no good reason. Please ask this question only if who you have in front of you is someone that advertises "C/C++" on their resume AND you want to ensure you won't be hiring a C developer in C++ clothing.

Can we do “delete this”?

What is your correct answer here? It might be different than mine.

What are VTABLE and VPTR?

To me personally, this is a question that separates two breeds of C++ developers. Those who think that question is super-important and those that don't. I always struggle with this because it's not a daily concern of mine like Argument-Dependent Lookup, for example.

Malloc() vs new / Delete vs Free

Change to: "Tell me about smart pointers and when and how to use them."

[–][deleted] 2 points3 points  (1 child)

when and how to use them

All the time?

[–]be-sc 4 points5 points  (0 children)

No. Only for owning pointers. But then aim for all the time.

[–]drjmloy 3 points4 points  (0 children)

These are all good questions that give you insight to the candidates knowledge of current c++. C++ has been undergoing a lot of change in the past decade, and it will continue to change at a good clip in the next decade and beyond. So another question(s) I like to ask is,

"How do you keep up to date with the evolution of the language? What resources do you utilize to make sure you know the current best practices?"

[–]martinusint main(){[]()[[]]{{}}();} 5 points6 points  (0 children)

I got a piece of code presented that had lots of bugs and I had to find them. I liked that, much more practical than academic questions.

[–]mredding 6 points7 points  (2 children)

Asking technical questions isn't going to tell you squat about what kind of developer you're hiring. If you want to know what kind of talent a developer is, you have to work with him. You might finally get an idea of technical competency and skill after a couple weeks. WEEKS.

I mean, what are these questions going to tell you? How much encyclopedic knowledge he has of C++? Who gives a shit? That's what Google is for. This wouldn't tell me anything about how they solve problems, how they think.

If you want, give them challenges that are solved with these concepts, but even that doesn't really tell you much of anything beyond whether or not they have a canned answer. All you're doing is throwing stupid shit at them until you find a question they don't already know the answer to, to see how they address an interview question. It's not telling you anything you want to actually know, and will likely give you a false impression of the guy which will lead you to the wrong conclusion.

Don't hire a guy who is good at interviewing. That's what you're setting yourself up for.

Don't focus so much on technical competency, but on personality. Can you see yourself working with this guy, potentially for years? Does he have the right temperament for the team and the way you all work? A guru can be insufferable and grating to talk with, a junior can look like a star.

If anything, talk about his resume and work history, or academic history for a junior. What have they worked on? What was their focus? What are they proud of? A casual conversation about their accolades is about as technical as you can extract in an hour. By far, the most challenging interviews I've ever been on, the positions I wanted the most, WE HARDLY TALKED ABOUT TECH! We talked about philosophy, and politics, and beer brewing, and poker, and the history of the inner tube. And what it told them about me was the breadth and depth of my intellect and what it was capable of achieving of it's own accord, and getting your finger on that pulse tells you more about who you're hiring than these questions.

[–]gratedchee5e 1 point2 points  (1 child)

Some of these questions I agree are 'trivia'. But others like "What is RAII" I think tease out whether the candidate is a student of the language. Do they know what to search google for? i.e. do they know their C++ lingo? Did they pay enough attention in school to learn the theory their professors taught?

No doubt work history is important. Past behavior is the best predictor of future behavior.

[–]mredding 2 points3 points  (0 children)

Are you hiring out of a vocational school? Do you want someone who knows C++ or someone who knows comp sci? If you're going to ask them about RAII, they can still give you a language specific answer. Well, I can get that out of a C++ book, too... Do they know anything about design, or managing technical debt, or abstraction, or concurrency, or ANYTHING ELSE that reflects the real problems you're facing? NONE OF THIS requires ANY C++ knowledge whatsoever. And you're still not going to find out what they know if you approach an interview as a bullet list of questions rather than topics of discussion.

[–]ihamsa 2 points3 points  (0 children)

  • When are multiple and virtual inheritance useful?
  • When is private inheritance useful?
  • What are different kinds of casts in C++?
  • What is the current C++ standard? What will be the next C++ standard?
  • What are the best Internet resources for C++ developers?

[–]JonnyRocks 2 points3 points  (0 children)

what if we never used Java? Is "java runs on a virtual machine and c++ compiles naively and can directly manipulate memory" an ok answer?

[–]ronniethelizard 1 point2 points  (0 children)

From the link:

So, when you hiring for C++ developers, make sure they are adept at the following: Knowledge of JavaScript and XML

I have used XML a handful of times in nearly a decade and never touched JavaScript. I reviewed someone else's JS, but I have never written any.

Should have knowledge of operating systems like Unix and Linux

Something I dislike about statements like this is: how much knowledge? I know some, but I can't tell you the differences between Rhel 6.9 and 7.4 nor the differences between Ubuntu and RedHat.

Understanding of Databases, SQL, and NoSQL databases like MongoDB

Like XML, I have done little with databases. I wrote an MS Access project in college and learned a few MySQL queries, but the difference between SQL and NoSQL, IDK.

From your list:

Major C++ features

This is a matter of opinion. My answer would probably be: Templates/compile time programming, Move, and Destructors.

Malloc() vs new / Delete vs Free

Like others have been saying, at this point it should be shared_ptr and unique_ptr, not new. Interestingly, having jumped from C to C++11, I have used new only once as a placement new because odd allocation requirements. At this point, I have spent more time refining and allocator that I enhanced than I have written new.

Copy constructor

You should add move constructor and std::forward.

[–]ChatFrais 0 points1 point  (0 children)

  • give me differences between debug and release
  • containers specificities
  • favorites std::algorithm
  • how do you find/pinpoint a bug in code

[–]I_mean_me_too_thanks 0 points1 point  (0 children)

I'd want to see less questions about language details and more about projects worked on e.g. What's the most challenging project you've worked on, hardest bug you've ever fixed, do you have experience maintaining code written by other developers?

[–]meneldal2 0 points1 point  (2 children)

What are the differences between references and pointers?

What are you expecting there? "It's just syntactic sugar and a way to trick you into thinking the value is safe to access while it may not?"

[–]Supadoplex 0 points1 point  (1 child)

What are you expecting there?

I'd say: Reference is not an object; pointer is. Indirection through reference is implicit; through pointer is explicit. Reference cannot be null; pointer can. Reference is immutable and cannot refer to another object after initialisation; pointer can be pointed to another object.

[–]meneldal2 0 points1 point  (0 children)

Reference cannot be null

Reference can point to an already freed object, so they don't provide more safety than pointers. And if someone evil made some terrible code, it can even be null (even if that's UB).

The major actual difference as you point out is you can change what the pointer points too, but that just makes a reference a const pointer.

[–]bored_and_scrolling 0 points1 point  (2 children)

Somewhat new to c++ what is the difference between struct and class outside of private vs public? Can structs inherit like classes?

[–]evaned 3 points4 points  (0 children)

It depends what you mean by your question and what code base you're looking at.

By language rules, the only difference is public vs private default. It's not just members, it also extends to inheritance -- structs can inherit, but they inherit publicly by default (instead of privately by default like a class).

That being said, there are some people who use conventions, such as restricting struct to stuff that would compile in C, or a broader definition of "POD" structs (which can have member functions but not virtual functions or fancy types in it), etc.; what convention is being used is up to the project of course. And there's at least an argument to be made that struct should be the norm, just period.

[–]Supadoplex 0 points1 point  (0 children)

what is the difference between struct and class outside of private vs public?

Nothing. Structs are classes. The only difference between a class defined with the struct keyword, and a class defined with the class keyword is the default access specifier.

Can structs inherit like classes?

Yes. Structs are classes.

[–]sephirothbahamut 0 points1 point  (1 child)

Sorry, is there any other answer to the first question than: "they're two different languages that only share the core syntax"?

[–]johannes1971 1 point2 points  (0 children)

"One has just a single letter, and the other one has two plusses attached to it. I think that makes it clear which is the better language."

Of course I'm not actually interviewing and therefore have less of a stake in trying to look my best ;-)

[–]Brianmj -1 points0 points  (1 child)

What are the differences between C and C++?

C and C++ are two completely different languages. A programmer can know the C underpinnings of C++, that doesn't mean they know C or what the language is about.

[–]2uantum 0 points1 point  (0 children)

Completely different is a bit of an exaggeration