ObjectOrientedProgramming (OOP) - itzjac/cpplearning GitHub Wiki

Any program can be designed without the OOP.

This programming paradigm became popular during the 90's and there were strong reasons to believe it will solve all problems.

But with the years have passed, and specially in the real time applications, this paradigm doens't solve all the problem around software design.

It is a tool, and knowing the problem it is possible to take the best out of it. In combination with other paradigms it is an amazing tool and helps organize - reuse - communicate a design around a program.

Here we will cover only the foundations of the OOP in C++.

Structures

Points

Triangles

Definition

Declaration

Passing struct by reference

Classes

Properties (members)

Actions (functions)

Code Unit

Access public - private

Blue prints and objects (instances)

Some objects of this paradigm, modelling a problem around objects

  • Intuition
  • Organization
  • Data hiding
  • Code reuse

Scope resolution operator for functions

Constructors: initialize members to values, allocate dynamic memory

Destructors: dellocate dynamic memory

Indirect membership operator (->) instead of (*myObject).fuction

Definition an Implementation (.h & .cpp files)

Remember from chapter 1, cpp cn have cxx extension too and work along with the headers the same way.

Object Interaction

Define how they can interact

Inheritance

Polymorphism

Namespace

Quiz

  • About constructors
  • Reasons to ship headers and not implementation files
  • Can you provide member function definition inside a class body?
  • True or False statements about classes, structs
  • Difference between class and struct
  • code analysis of a class: synthetic constructor, destructor, asigment, copy
  • Allocation Deallocation in constructor destructor
  • About data private and taking care of its integrity
  • Reasons not to use OOP
  • Definition declaration of header and cpp files