Notepad Flashcards
What do namespaces do in C++
Namespaces in C++ are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.
What is a template in C++
A template in C++ is a feature that allows functions and classes to operate with generic types.
It is used for code reusability and to avoid redundancy in code for different data types.
What is the purpose of the virtual keyword in C++?
To allow method overriding in derived classes
What is operator overloading
Operator overloading allows operators to be redefined and used in different ways depending on their arguments.
The explanation could be more detailed, such as explaining that it allows the same operator to perform different
operations based on the types of operands. An example would strengthen this answer.
What will the output here be;
int a = 10;
int b = a++;
cout «_space;a «_space;” “ «_space;b;
The output will be 11 10. The post-increment operator ++ increments a after its
value is assigned to b. So, b gets the original value of a (10), and a becomes 11.
What is the concept of Overloading;
Overloading in C++ refers to the ability to have multiple functions with the same name
but different parameters (function overloading) or to have operators work differently
depending on their operands (operator overloading). It allows functions or operators to
behave differently based on the context of their use.
How do you access a substring of string s
s.substr(beginning_substr_index, len_of_substr);
Difference between pointer and reference;
A pointer is a variable that stores the memory address of another variable.
A reference, on the other hand, is an alias for another variable.