Daily C++ Interview is an around 150 day program and it offers you questions and coding problems organized around different topics, such as polymorphism, smart pointers, modern C++ best practices, etc. Some questions come back multiple times during the 5 months so that you better remember, yet there are more than 120 unique questions.
I recommend you take a question every day, try to answer it on your own and then read the answer. The depth of the answers is limited due to space and time reasons, but for almost every question you get a list of references, so youre more than welcome to continue the quest.
Before starting to take the questions, lets discuss the different kinds of interviews and see how Daily C++ Interview will help you nail them.
The different typical interview processes
In order to better understand where Daily C++ Interview can help you prepare for your next job interview, lets differentiate between two typical interview processes.
The Big Tech style interview process
One of them, the more usual one nowadays is very competitive and has several rounds. It starts with an initial screening call that is often conducted by a non-technical person, a recruiter. However, Ive heard and seen cases where even the first contacts were made by engineers so that they can see earlier whether youd be a good fit for the team.
This first round might have been preceded by a 0th round with some takeaway exercise. The idea behind is that if you cannot prove a certain level of expertise, they dont want to waste their time on the applicant. Sometimes this exercise is way too long and many of us would outright reject such homework. If its more reasonable, you can complete it in an hour or two.
After the screening, there is a technical round that is usually quite broad and there is not a lot of time to go deep on the different topics. Its almost sure that youll get an easy or medium-level Leetcode-style coding exercise. For those, you must be able to reason about algorithmic complexities and its also very useful if you are more than familiar with the standard library of your language. Apart from a coding exercise, expect more general questions about your chosen language.
If youre reading this book, most probably thats C++ for you. By understanding your language deeper - something this book helps with - youll have a better chance to reach the next and usually final round of interviews, the so-called on-site. Even if its online, it might still be called on-site and its a series of interviews you have to complete in one day or sometimes spanned over one day.
It typically has 3 or 4 different types of interviews.
- Behavioural interviews focusing on your soft skills
- A system design interview where you get a quite vague task to design a system. You have to clarify what the requirements are and you have to come up with the high-level architecture and dig deeper into certain parts
- There are different kinds of coding interviews
- Coding exercises - You wont be able to solve coding exercises with what you learn in this book, but youll be able to avoid some pitfalls with a deeper understanding of the language. Daily C++ Interview helps you to achieve that understanding. In addition, you must practice on pages like Leetcode, Hackerrank, Codingame, etc
- Debug interview. You receive a piece of code and you have to find the bugs. Sometimes this can be called a code review interview. Its still about finding bugs. Personally, I find it a bit deeper than a simple coding exercise. In a coding interview, you are supposed to talk about design flaws, code smells, and testability. If you know C++ well enough, if you try to answer some of the questions of Daily C++ Interview on a day-to-day basis, youll have a much better chance to recognize bugs, smells, flaws and pass the interview.
Given the several rounds, scheduling conflicts and sometimes flying in for the last round, such a process can go quite long, it can easily take at least a month if not two.
The shorter interview process
Certain companies try to compete for talent by shortening their interview cycles and making a decision as fast as possible. Often they promise a decision in less than 10 days. Usually, they dont offer so competitive packages - but even that is not always true - so they try to compete on something else.
A shorter decision cycle obviously means fewer interviews. Sometimes this approach is combined with the lack of coding interviews - at least for senior engineers. The idea behind is that many engineers despise the idea of implementing those coding exercises. They find it irrelevant and even derogative to implement a linked list. Instead, they will ask questions that help evaluate how deep you understand the given programming language.
As this book is concentrating on C++-specific detailed knowledge and not on coding, youll find it helpful in any type of interview process.
auto
and type deduction
In this chapter, we are going to learn about C++s type deduction rules and about how to use the auto
keyword that was introduced in C++11.
Question 1: Explain auto type deduction!
auto
type deduction is usually the same as template type deduction, but auto
type deduction assumes that a braced initializer represents a std::initializer_list
, and template type deduction doesnt hold such premises.
Here are a couple of examples:
1
int
*
ip
;
2
auto
aip
=
ip
;
// aip is a pointer to an integer
3
const
int
*
cip
;
4
auto
acip
=
cip
;
// acip is a pointer to a const in\
5
t (the value cannot be modified, but the memory address i\
6
t points can)
7
const
int
*
const
cicp
=
ip
;
8
auto
acicp
=
cicp
;
// acicp is still a pointer t a co\
9
nst int, the constness of the pointer is discarded
10
11
auto
x
=
27
;
// (x is neither a pointer nor a r\
12
eference), x's type is int
13
const
auto
cx
=
x