C++ Flashcards

Basic knowledge about C++ (18 cards)

1
Q

What is the difference between pointers and references?

A

A pointer is the address of an object while a reference is another name for an existing object.

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

Explain the concept of Object Oriented Programming (OOP)

A

It means that the language is built around the conecpt of objects. It relies on 4 principles: encapsulation, inheritance, polymorphism, and abstraction

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

What is the Encapsulation principle?

A

It is the principle of wrapping related data and their methods into a structed unit.

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

What is the Inheritance principle?

A

It is the principle that a class can inherit the propreties and functions of other class. this promotes code reuse.

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

What is the Abstraction principle?

A

It is the principle of hiding unnecessary information and functionning from user or other classes that may use/reference it.

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

What is the Polymorphism principle?

A

It is the principle that object of different classes can be treated as a common base class. Presenting the same interface for different data types.

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

What is the Single Responsibility Principle (SRP)?

A

it is the principle that a class should only have 1 responsibility/job.

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

What is the Open/Closed Principle (OCP)?

A

It is the principle that software entities (classes, modules, functions, etc.) shoudl be open to extenstion but closed for modifications.

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

What is the Liskov Substitution Principle (LSP)?

A

It is the principle that objects of a superclass should always be replacable by objects and a subclass without affecting the correctness of the program.

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

What does the correctness of a program mean?

A

It means that it is a program provides a valid output for every possible input.

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

What is the Interface Segregation Principle (ISP)?

A

It is the principle that a client should never have to implement an interface that it doesnt use or depend on it.

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

What is the Dependency Inversion Principle (DIP)?

A

It is the principle thats abstraction should be used to decouple high-level modules from low-level modules, making the dependency on the abstraction rather than the implementations.

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

What is the Resource Acquisition Is Initialization (RAII)?

A

It is the principle that resources (memory, file handles, etc) are acquired and released within the lifetime of an object.

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

What is the The Rule of Three/Five/Zero?

A

It is the priniciplee that guides the implementation of constructors, destructors, and assignment operators:
-Rule of zero: if you can avoid implementing default operations, do so.
-Rule of three: if a class needs a custom destructor, copy constructor, or copy assignement, it probably needs all three.
-Rule of Five: if you need to define any of these functions, you likely need all five. (Destructor, copy Constructor, Copy Assignment Operator, Move Constructor, Move Assignment Operator).

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

What is the difference between C and C++?

A

C is based on procedural programming paradigm while C++ is mostly a superset of C made for OOP

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

What are the main feature of C++?

A

The maion features of C++ are that it is OOP, allows operator overloading, exception handling and tamplate and generic programming.

16
Q

Describe virtual functions and pure virtual functions.

A

A virtual function is a defined function that can be overriden by devrived classes. A pure virtual function is a declred function with no implementation that forces devrived classes to implement it.