Notepad Flashcards

1
Q

What do namespaces do in C++

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a template in C++

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of the virtual keyword in C++?

A

To allow method overriding in derived classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is operator overloading

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What will the output here be;

int a = 10;
int b = a++;
cout &laquo_space;a &laquo_space;” “ &laquo_space;b;

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the concept of Overloading;

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you access a substring of string s

A

s.substr(beginning_substr_index, len_of_substr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Difference between pointer and reference;

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly