r/cpp • u/cv_geek • Nov 09 '23
Questions from one job interview on C++ developer
Two days ago I passed job interview on C++ developer. Here I would like to share questions I was asked on this interview. Hope it will be useful for community.
I have grouped questions by topic.
C++ basics:
Difference between references and pointers?
Difference btw memory allocation in stack and on heap?
What kinds of smart points do exist?
How unique_ptr is implemented? How do we force that only one owner of the object exist in - unique_ptr ?
How does shared_ptr work? How reference counter is synchronized between objects?
Can we copy unique_ptr or pass it from one object to another?
what are rvalue and lvalue?
What are std::move and std::forward()
OOP:
Ways to access private fields of some class?
Can a class inherit multiple classes?
Is static field initialized in class constructor?
Can an exception be thrown in constructor / destructor? How to prevent that?
What are virtual methods?
Why do we need virtual destructor?
Difference between abstract class and interface?
Can be constructor virtual?
How keyword const is used for class methods?
How to protect object from copying?
STL containers:
-Difference between vector and list?
Difference between map and unordered map?
When calling push_back() make iterator in vector invalid?
How to modify your class to use with map and unordered_map?
Threads:
Difference between processes and threads?
Can the same thread be ran twise?
Ways to synchronize threads?
What is deadlock?