OO

Tell, don’t ask

Law of Demeter for functions

An object should only call:

  • Any parameters that were passed in to the method
  • Any objects it created
  • Any directly held component objects

Overloading versus Overriding

Overloading generally means that you have two or more functions in the same scope having the same name. The function that better matches the arguments when a call is made wins and is called. Important to note, as opposed to calling a virtual function, is that the function that’s called is selected at compile time. It all depends on the static type of the argument.

Overriding is something completely different. It doesn’t compete with overloading. Function overriding is how polymorphism works in C++. It means that if you have a virtual function in a base class, you can write a function with the same signature in the derived class. The function in the derived class overrides the function of the base.

Link: Stackoverflow