FAQ Database Discussion Community


calling a virtual function through a reference: derived class' override gets called

c++,polymorphism,dynamic-binding
I have the following code: #include <iostream> using namespace std; class Parent { public: virtual void f() { cout << "Parent" << endl; } }; class Child : public Parent { public: void f() { cout << "Child" << endl; } }; void t1(Parent * p) { p->f(); } void...

Version of __CLASS__ that binds at run-time rather than at compile-time

php,runtime,subclass,classname,dynamic-binding
In the following PHP code I would like to replace the __CLASS__ magic constant in the Foo class with a function __X__() (or something similar) so that when the method hello() is called from an instance $bar of the Bar class, it prints hello from Bar (instead of hello from...

Local dynamic binding in common lisp

closures,common-lisp,dynamic-binding
Honnestly, I'm not sure I fully understand what it means for a binding to be "dynamic" versus "lexical". But I understand that when I use defvar or defparameterto define a binding, 1. it declares a global variable 2. the binding is declared "special", so that it can be shadowed by...

Dynamic binding for dynamic query on Native Dynamic SQL

oracle,performance,plsql,dynamic-binding
I find myself in a situation where my code needs to execute a dynamic statement formed by an unknown number (at least one, but could be more) of other dynamic statements concatenated by 'intersect' and 'union' operators. Here's an example with three querys (I know that this could be resolved...

How to create my own object properly out of stdClass object

php,constructor,dynamic-binding
I'm creating instance of person according to data that i get from API response. The data returns as \stdClass and i want to convert it to my own object. Is there a way to pass all the calls in the constructor and make something more elegant? Class Person { protected...