class Base { }; class Derived : public Base { }; Base *b = …; Derived *d = …;
b = dynamic_cast<Base *>(d);
b = dynamic_cast(Base *, d);
b = dynamic_cast(d);
d = dynamic_cast(b);
d = dynamic_cast<Derived *>(b);
d = dynamic_cast(Derived *, b);
#ifndef FOO_H_INCLUDED … class declaration here … #define FOO_H_INCLUDED #endif
#ifndef
should be #ifdef
.
define
is in the wrong place.
What’s the best way to find out if bit #7 (where bit #0 is the LSB)
of the int v
is set?
if (v.bit(7))
if (v & 00000080)
if (v && (1 << 7))
if ((v>>7) & 01)
if ((v<<24) < 0)