Insight into advanced C++ OOP

Source and Header

The reasons to separate are:

  • To improve build times. Faster recompiles: If your implementation is split up into separate compilation units, you only need to recompile the ones that change when making edits.
  • To link against code without having the source for the definitions.
  • To avoid marking everything “inline”.

Polymorphism in C++

Compile time polymorphism

Function/Operator Overloading

Runtime polymorphism

Function overriding on the other hand occurs when a derived class has a definition for one of the member functions of the base class.

  • To avoid ambiguity error when multiple inheritence.

  • Virtual functions are functions that can be overridden in derived class with the same signature.

  • Virtual functions enable run-time polymorphism in a inheritance hierarchy.

  • If a function is ‘virtual’ in the base class, the most-derived class’s implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference. In non-virtual functions, the functions are called according to the type of reference or pointer.

  • Static functions are class specific and may not be called on objects. Virtual functions are called according to the pointed or referred object.

  • Virtual function has a VPTR that poccesses some memory.

  • A member function can be virtual even if we have not uses virtual keyword with it. When a class has a virtual function, functions with same signature in all descendant classes automatically become virtual. We don’t need to use virtual keyword in declaration of fun() in B and C. They are anyways virtual.

  • A base class function can be accessed with scope resolution operator even if the function is virtual.

Replacing system-wide `nodejs` by another version managed by `nvm`

Some legacy codes are not compatible with latest nodejs. nvm helps with this situation to provide older stable version.

Uninstall system-wide nodejs and install nvm via package management.

Config fish-shell:

1
2
3
4
5
6
function nvm
bass source (brew --prefix nvm)/nvm.sh --no-use ';' nvm $argv
end

set -x NVM_DIR ~/.nvm
nvm use default --silent

Take effect immediately:

source ~/.config/fish/config.fish

An extension to fish-shell is bass.

Bass makes it easy to use utilities written for Bash in fish shell.

An extension to homebrew is cask.

Cracking Java Interview

A list of frequently asked Java questions

  • Overriding vs overloading

    Overriding happens at subclass while overloading happens in the same class. Also, overriding is a runtime activity while overloading is resolved at compile time.

  • Difference between Hashtable and Hashmap, ArrayList and Vector

    Synchronized or not.

  • Thread-safe and synchronization

Machine-Learning-for-Game-TechStack

  • Skymind.ai

  • Keras

  • blueberrymusic

  • Deep Learning, Vol. 1: From Basics to Practice

Reform on course taking

  • Withdraw a course if workload is too heavy.

  • Auditory sense stimulates comprehension when learning for first time. Multimedia records and replays are required.

  • Paper-based books and notes may fit for efficient reviewing. Notes on screens are not yet quite suitable for looking over. Textbooks appear to be loquacious at first glance, but include meaningful extensions.

JDK for macOS

You need the following to distinguish between built-in and user installed versions of JDK.

/usr/libexec/java_home -verbose