Example Code
Suppose some function takes an object of type A
as its argument, and wishes to perform some additional operation if the object passed is an instance of B
, a subclass of A
. This can be accomplished using dynamic_cast
as follows.
A similar version of my_function
can be written with pointers instead of references:
Read more about this topic: Dynamic Cast
Famous quotes containing the word code:
“... the self respect of individuals ought to make them demand of their leaders conformity with an agreed-upon code of ethics and moral conduct.”
—Mary Barnett Gilson (1877?)
“Many people will say to working mothers, in effect, I dont think you can have it all. The phrase for have it all is code for have your cake and eat it too. What these people really mean is that achievement in the workplace has always come at a priceusually a significant personal price; conversely, women who stayed home with their children were seen as having sacrificed a great deal of their own ambition for their families.”
—Anne C. Weisberg (20th century)