- Mutable keyword?
- keyword is the key to make exceptions to const
- mutable data member is allowed to change during a const member function
- mutable data member is never const even when it is a member of a const object
- a const member function may change a mutable member
- Something you can do in C but not in C++?C++ applications generally slower at runtime and compilation - input/output
- Difference between calloc and malloc?
- malloc: allocate s bytes
- calloc: allocate n times s bytes initialized to 0
- What will happen if I allocate memory using new & free memory using free? WRONG
Difference between printf and sprintf?
sprintf: a function that puts together a string, output goes to an array of char instead of stdout
printf: prints to stdout
printf: prints to stdout
map in STL?
- used to store key - value pairs, value retrieved using the key
- store data indexed by keys of any type desire instead of integers as with arrays
- maps are fast 0(log(n)) insertion and lookup time
- std::map<key_type, data_type>EX:Std::map<string, char> grade_list //grade_list["john"] = b
When will we use multiple inheritance?
- use it judiciously class
- when MI enters the design scope it becomes possible to inherit the same name (function/typedef) from more than one base class == ambiguity
- C++first identifies the function thats the best match for the call
- C++resolves calls to overload before accessibility, therefore the accessibility of Elec_Gadget() checkout is never evaluated because both are good matches == ERROR
- resolve ambiguity mp.Borrowable_Item::checkOut(); mp.Elec_Gadget::checkOut(); //error because trying to access private
- deadly MI diamond: anytime you have an inheritance hierarchy w/ more than one path between a base class and a derived classEX:FileInput File Output FileIOFile//File and IOFile both have paths through InputFile and OutputFile
Multithreading - C++does not have a notion of multithreading, no notion of concurrency
Why is the pre-increment operator faster than the post-increment operator? pre is more efficient that post because for post the object must increment itself and then return a temporary containing its old value. True for even built in types
What is a hash and what would you use it for?
What is a dot product and what is a cross product - what would you use them for?
What is 2 ^ 101?