Dynamic polymorphism

Go down

Dynamic polymorphism

Post  meodingu on Tue Jan 11, 2011 5:11 pm


Dynamic polymorphism
[edit]Inheritance
Variable pointers (and references) to a base class type in C++ can refer to objects of any derived classes of that type in addition to objects exactly matching the variable type. This allows arrays and other kinds of containers to hold pointers to objects of differing types. Because assignment of values to variables usually occurs at run-time, this is necessarily a run-time phenomenon.
C++ also provides a dynamic_cast operator, which allows the program to safely attempt conversion of an object into an object of a more specific object type (as opposed to conversion to a more general type, which is always allowed). This feature relies on run-time type information (RTTI). Objects known to be of a certain specific type can also be cast to that type with static_cast, a purely compile-time construct which is faster and does not require RTTI.

Cartier Tank Francaise Ladies Watch replica
Home improvement
avatar
meodingu
Member
Member

Number of posts : 307
Registration date : 2010-09-28

View user profile

Back to top Go down

Re: Dynamic polymorphism

Post  stevenlee on Tue Oct 18, 2011 10:05 am

C++ also provides a dynamic_cast operator, which allows the program to safely attempt conversion of an object into an object of a more specific object type (as opposed to conversion to a more general type, which is always allowed). This feature relies on run-time type information (RTTI). Objects known to be of a certain specific type can also be cast to that type with static_cast, a purely compile-time construct which is faster and does not require RTTI.

stevenlee
Member
Member

Number of posts : 2
Registration date : 2011-10-18

View user profile

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum