C++ Flashcards
Basic knowledge about C++ (18 cards)
What is the difference between pointers and references?
A pointer is the address of an object while a reference is another name for an existing object.
Explain the concept of Object Oriented Programming (OOP)
It means that the language is built around the conecpt of objects. It relies on 4 principles: encapsulation, inheritance, polymorphism, and abstraction
What is the Encapsulation principle?
It is the principle of wrapping related data and their methods into a structed unit.
What is the Inheritance principle?
It is the principle that a class can inherit the propreties and functions of other class. this promotes code reuse.
What is the Abstraction principle?
It is the principle of hiding unnecessary information and functionning from user or other classes that may use/reference it.
What is the Polymorphism principle?
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.
What is the Single Responsibility Principle (SRP)?
it is the principle that a class should only have 1 responsibility/job.
What is the Open/Closed Principle (OCP)?
It is the principle that software entities (classes, modules, functions, etc.) shoudl be open to extenstion but closed for modifications.
What is the Liskov Substitution Principle (LSP)?
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.
What does the correctness of a program mean?
It means that it is a program provides a valid output for every possible input.
What is the Interface Segregation Principle (ISP)?
It is the principle that a client should never have to implement an interface that it doesnt use or depend on it.
What is the Dependency Inversion Principle (DIP)?
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.
What is the Resource Acquisition Is Initialization (RAII)?
It is the principle that resources (memory, file handles, etc) are acquired and released within the lifetime of an object.
What is the The Rule of Three/Five/Zero?
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).
What is the difference between C and C++?
C is based on procedural programming paradigm while C++ is mostly a superset of C made for OOP
What are the main feature of C++?
The maion features of C++ are that it is OOP, allows operator overloading, exception handling and tamplate and generic programming.
Describe virtual functions and pure virtual functions.
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.