13.01.2015 Views

Pensar en C++ (Volumen 1) - Grupo ARCO

Pensar en C++ (Volumen 1) - Grupo ARCO

Pensar en C++ (Volumen 1) - Grupo ARCO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

✐<br />

✐<br />

✐<br />

“Volum<strong>en</strong>1” — 2012/1/12 — 13:52 — page 457 — #495<br />

✐<br />

15.9. Sobrecargar y redefinir<br />

int<strong>en</strong>ta hacer.<br />

15.9. Sobrecargar y redefinir<br />

En el capítulo 14 se vio que redefinir una función sobrecargada <strong>en</strong> la función base<br />

oculta todas las otras versiones de esa función. Cuando se involucra a las funciones<br />

virtuales el comportami<strong>en</strong>to es un poco difer<strong>en</strong>te. Consideremos una versión modificada<br />

del ejemplo NameHiding.cpp del capítulo 14:<br />

//: C15:NameHiding2.cpp<br />

// Virtual functions restrict overloading<br />

#include <br />

#include <br />

using namespace std;<br />

class Base {<br />

public:<br />

virtual int f() const {<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!