jimin-kiim / OOP

Object Oriented Programming
0 stars 0 forks source link

Fundamental Concepts of OOP #3

Open jimin-kiim opened 2 years ago

jimin-kiim commented 2 years ago
jimin-kiim commented 1 year ago

ADT(Abstract Data Type)

in OOP

Class

Object

jimin-kiim commented 1 year ago

Object

Encapsulation, Information Hiding

Benefits of data encapsulation

protection keywords for encapsulation

jimin-kiim commented 1 year ago

Inheritance : Extension and Contraction

Inheritance relationship

IS-A relationship

Benefits of Inheritance

Cost of Inheritance

Constructor / Destructor in Inheritance

jimin-kiim commented 1 year ago

Polymorphism

Overloading

void Child::example(int a) {   Parent::example(12); // do parent code   cout << "in child code\n"; // then child code }



### Polymorphic variable
- a variable declared as one type but in fact holds a value of different type
  - can reference more than one type of object
- derives their power from interaction with inheritance, overriding and substitution
- when a method is overridden, the code executed will be determined by the current value of a polymorphic variable, not its declared type
- this : example of common polymorphic variable
### Generics (templates)
- a way of creating general tools or classes by parameterizing on types (not values)
  - developing code by leaving certain key types unspecified, to be filled in later
- both used with functions and with classes
  - [function template](https://github.com/jimin-kiim/CPP/issues/16#issuecomment-1352937437)
  - [class template](https://github.com/jimin-kiim/CPP/issues/16#issuecomment-1352937578)
jimin-kiim commented 1 year ago

Data Abstraction