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 517 — #555<br />

✐<br />

16.8. Por qué usar iteradores<br />

// a differ<strong>en</strong>t interface:<br />

Drawing d;<br />

d.add(new Circle);<br />

d.add(new Square);<br />

d.add(new Line);<br />

Plan p;<br />

p.push(new Line);<br />

p.push(new Square);<br />

p.push(new Circle);<br />

Schematic s;<br />

s.push_back(new Square);<br />

s.push_back(new Circle);<br />

s.push_back(new Line);<br />

Shape* sarray[] = {<br />

new Circle, new Square, new Line<br />

};<br />

// The iterators and the template function<br />

// allow them to be treated g<strong>en</strong>erically:<br />

cout

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

Saved successfully!

Ooh no, something went wrong!