Oct 20 2022 Flashcards
What is the syntax of inheritance
class Derived : public Base{
}
Derived class
-> 1 Default
-> 2 Single Input
Base
-> 3 Default
-> 4 Singe Input
You created object Base no input how are the constructors executed
1 then 2
Derived class
-> 1 Default
-> 2 Single Input
Base
-> 3 Default
-> 4 Singe Input
You created object Base one input how are the constructors executed
1 and 3
Derived(int x,int y):Base(x)
{
cout«“Param of Derived “«y«endl;
}
What is this constructor doing
Execute Base class on input constructor then run derived class constructor
A class can be used in two ways , What are the ways
A class can be Derived (IsA)
or
Object of that class be used ( hasA)
What type of members can a class have and what are they called collectively
Private
Public
Protected
Access Specifiers
Difference between
Private
Public
Protected
-> In main function you can only access public members
-> In a derived function of a derived class you can access public and protected only
-> All Are accessible with in its own class
What are the types of inheritance
simple
Hiearchial
MultiLevel Inheritance
Multiple Inheritance
What is Multi-path Inheritance
Combination of Multiple Inheritance and Hierarchal
What does Virtual key Word Do in multipath inheritance
Removes the ambiguity as to through which path the base base function is coming to the most derived class
class child : ______ Parent
What are the ways of inheritance
Public , all the members keep the original access Modifier
Protected , all the members keep the original access Modifier except for public which becomes protected
Private , all the members private
Generalization vs Specialization
Top-Down = Specialization ( Parent Class was Existing then we defined a base class)
Bottom-Up = Generalization ( Base class was existing then we defined a parent class) -> Purpose is to group to achieve polymorphism
What is function overriding in terms of classes
- Redefining a function of base class in derived class
- Function overriding is used for achieving runtime polymorphism
- Prototype of a overrides function must be exactly same as base class function
How do Virtual Functions work in derived class and base class
- Virtual functions are used for achieving polymorphism
- Base class can have virtual functions
- Virtual functions can be overrides in derived class
- Pure virtual functions must be overrides by derived class
How do Virtual Functions work in derived class and base class
- Virtual functions are used for achieving polymorphism
- Base class can have virtual functions
- Virtual functions can be overrides in derived class
- Pure virtual functions must be overrides by derived class