i want to be sure if i understand that corectly. If i have something like that:
Base* wsk = new Derived
and if i've done that with static-binding than wsk is type of Base, but Derived type object is still created? And wsk
is pointing to that Derived type object, but it cannot use methods from derived class, because wsk
is Base type? To sum up the most important question for me is that if wsk
except that it's Base type is still pointing to new object which is Derived type?
wsk
is of typeBase *
, notBase
norDerived
.It was initialised with a value that was (implicitly) converted from type
Derived *
. It points to aBase
object, which so happens to reside within aDerived
object.That means that
static_cast<Derived *>(wsk)
will give you a value that points to aDerived
.It may be that the representation of
wsk
is the same number as the representation ofstatic_cast<Derived *>(wsk)
, i.e. that the address of theBase
object is the same as the address of theDerived
object, but that is not guaranteed