jweinst1
8/16/2017 - 6:19 PM

uses reinterpret_cast to quickly call a child class method.

uses reinterpret_cast to quickly call a child class method.

int main() {
  //chaining call
  Base* b = new IntObj(8);
  Base* c = new IntObj(6);
  b->setNext(c)->setNext(new IntObj(4));
  std::cout << reinterpret_cast<IntObj*>(b)->getValue() << std::endl;
}