1/4
A curated flashcard deck covering the most important C++ concepts, language mechanics, and interview-relevant theory.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is C++?
general purpose programming language that is biased towards system programming.
supports object oriented programming (abstraction, encapsulation, inheritance, polymorphism)
supports generic programming (reusable containers/algorithms)
supports functional programming (programming paradigm based on the idea of building software by composing pure functions)
Why does C++ allow unsafe code?
to access hardware directly (e.g. to treat an integer as a pointer to (address of) a device register)
to achieve optimal run-time and space performance (e.g. unchecked access to elements of an array and unchecked access to an object through a pointer)
to be compatible with C
What unsafe C++ code practices should be avoided unless absolutely necessary?
don’t use casts
keep C-style []
arrays out of interfaces
hide them in the innards of high-performance functions and classes where they are needed and write the rest of the program using proper string
s, vector
s, etc.
avoid void*
keep them inside low-level functions and data structures if you really need them and present type safe interfaces, usually templates, to your users
avoid union
s
if you have any doubts about the validity of a pointer, use a smart pointer instead
don’t use “naked” new
and delete
use containers, resource handles, etc., instead
don’t use ...
-style variadic functions (“printf
style”)
avoid macros except for #include
guards
Why are some things left undefined in C++?
C++ is meant to exploit hardware directly and efficiently. C++ is meant deal with hardware entities (bytes, bits, words, addresses) they way they are provided on the machine.