C++Deck Flashcards
<p>What are the 3 different categories of data types present in C++?</p>
<p>Fundamental data types, User defined data types, Derived data types</p>
<p>Name the C++ fundamental data types</p>
<p>1. Boolean type (bool)<br></br>2. Character types (char, wchar_t)<br></br>3. Integer types (int, long long ...)<br></br>4. Floating-point types (double, long double ....)<br></br>5. Void</p>
<p>What is the void type?</p>
<p>1. Type with an empty set of values (no value applies to it).<br></br>2.Incomplete type that cannot be completed.</p>
<p>What is an incomplete type?</p>
<p>A type that is not defined or void type.</p>
<p>What is nullptr_t?</p>
<p>Answer:<br></br>1. nullptr_t solves previous ambiguity problems with NULL<br></br>2.nullptr_t is the type of the nullptr literal.<br></br>3.It is a distinct type that it's not itself a pointer type.<br></br><br></br>Read more: <br></br>https://dzone.com/articles/what-exactly-nullptr-is-in-c</p>
<p>What RAII abbreviation means?</p>
<p>Resource Acquisition In Initialization</p>
<p>What is RAII Intent?</p>
<p>Answers:<br></br>1. To guarantee the release of a resource at the end of scope.<br></br>2.To guarantee no memory leaks<br></br><br></br>Read more: <br></br>http://www.vishalchovatiya.com/7-advance-cpp-concepts-idiom-examples-you-should-know/#Return-Type-Resolver</p>
<p>What is example RAII Implementation?</p>
<p>Answer:<br></br>1.Wrap resource into a class<br></br>2.Resource acquired in the constructor immediately after it's allocation<br></br>3.Destructor automatically releases resource<br></br>4.Resource used via interface<br></br><br></br>Read more: <br></br>http://www.vishalchovatiya.com/7-advance-cpp-concepts-idiom-examples-you-should-know/#Return-Type-Resolver</p>
<p>Why RAII is imporant?</p>
<p>Answer:<br></br>1. To not forget to release resource.<br></br>2. If a function returns early (throws, returns, etc...) resource may be leaked.<br></br><br></br>Read more:<br></br>http://www.vishalchovatiya.com/7-advance-cpp-concepts-idiom-examples-you-should-know/#Return-Type-Resolver</p>
<p>What are RAII usecases?</p>
<p>Answer:<br></br>In acquisition/release of resource with:<br></br>1)new/delete (memory)<br></br>2)lock/unlock (mutex)<br></br>3)open/close (file)<br></br>4)and others<br></br><br></br>Read more:<br></br>http://www.vishalchovatiya.com/7-advance-cpp-concepts-idiom-examples-you-should-know/#Return-Type-Resolver</p>
<p>What is the intent of return type resolver idiom?</p>
<p>Answer:<br></br>To deduce the type of the object being initialized or assigned to.<br></br><br></br>Read more:<br></br>http://www.vishalchovatiya.com/7-advance-cpp-concepts-idiom-examples-you-should-know/#Return-Type-Resolver</p>
<p>What is NULL?</p>
<p>NULL is a MACRO that is evaluated to integer with value 0</p>
<p>What is the intent of Type Erasure?</p>
<p>Answer:<br></br>To create generic container that can handle variety of concrete types.</p>
<p>What we refer to when we say the implementation's data model?</p>
<p>The sizes of the fundamental data types that are made by each implementation is referred to as the data model.</p>
<p>What are the four data models that found wide acceptance?</p>
<p>int/long/pointer notation (size in bytes)<br></br><br></br>32 bit systems:<br></br>LP32 (2/4/4 Win16) or ILP32 (4/4/4 Win32, Unix)<br></br>64 bit systems<br></br>LP64 (4/4/8 Win64) or ILP64 (4/8/8 Unix)</p>
<p>What are the integer types modifiers?</p>
<p>Signedness: signed (default) and unsigned.<br></br>Size: short (at least 16 bits) and long (at least 32 bits) and long long (C++11 at least 64 bits).</p>
<p>When integer types overflow is undefined?</p>
<p>When you overflow a signed integer.</p>
<p>At least how many bits is short?</p>
<p>16</p>
<p>At least how many bits is int?</p>
<p>16</p>
<p>At least how many bits is long?</p>
<p>32</p>
<p>At least how many bits is long long?</p>
<p>64</p>
<p>What is STL array?</p>
<p>STL array is fixed size array implementation from the standard library</p>
<p>What are the advantages of STL array over C array?</p>
<p>STL array doesn't degenerate to pointer when passed to function and it knows it's size</p>
<p>Where is STL array stored on the stack or on the heap?</p>
<p>On the stack</p>
<p>What does the const member function do?</p>
<p>1) Function declared const can be called for any object const or non const object<br></br>2) It doesn't allow modification on the object which calls them</p>
<p>What is an lambda function?</p>
<p>Short snippets of code that <br></br>1) Not worth naming<br></br>2) Not reused</p>
<p>Write to list lambda function syntax?</p>
<p>[ capture list ] (parameters) -> return-type <br></br>{ <br></br> method definition<br></br>}</p>
<p>What are lambda functions benefits?</p>
<p>1) They have application with generic functions like std::for_each, because it's not appropriate to create a new class for a specific algorithm.<br></br>2) Zero cost abstraction<br></br>3) Code becomes compact, structured, expressive.</p>
<p>When is the notion of invariant applied?</p>
<p>It is central to the design of classes.</p>
<p>What type of language is C++ (compiled or not compiled).</p>
<p>Compiled.</p>
<p>What are the steps for generating a C++ program?</p>
<p>1) Source text is processed by a compiler producing object files.<br></br>2) Object files are linked together producing executable file.</p>
<p>Is a C++ program compiled on one computer portable on another?</p>
<p>No, an executable C++ programs is created for specific hardware/system combination.</p>
<p>When we talk about portability of C++ program what do we mean?</p>
<p>Portability of source code. That is the source code could be successfully compiled and run on a variety of systems.</p>
<p>What is statically type language?</p>
<p>The type of every entity (object, value, name, expression) must be known to the compiler at its point of use.</p>
<p>What does the type of object determine?</p>
<p>The set of operations applicable to it and set of possible values.</p>
<p>What does {} indicate in C++?</p>
<p>Grouping</p>
<p>What does // indicate in C++?</p>
<p>Comment</p>
<p>What is main function?</p>
<p>Every program must have exactly one main function, it's where the program starts its execution.</p>
<p>What does non-zero value returned from main mean?</p>
<p>That the program has failed in some way.</p>
<p>What is a string literal?</p>
<p>A sequence of characters surrounded by double quotes.</p>
<p>What is a declaration?</p>
<p>1) A declaration is a statement that introduces a name to the program.<br></br>2) A declaration specifies the type of the name to inform the compiler what kind of entity the name refers to<br></br></p>
<p>It specifies all that's needed to use a function or a type.</p>
<p>What is an object?</p>
<p>An object is some memory that holds a value of some type.</p>