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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

✐<br />

✐<br />

✐<br />

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

✐<br />

Capítulo 16. Introducción a las Plantillas<br />

<strong>en</strong>cu<strong>en</strong>tra <strong>en</strong> el archivo de cabecera. Aquí t<strong>en</strong>emos un pequeño test que muestra las<br />

capacidades de la propiedad:<br />

//: C16:OwnerStackTest.cpp<br />

//{L} AutoCounter<br />

#include "AutoCounter.h"<br />

#include "OwnerStack.h"<br />

#include "../require.h"<br />

#include <br />

#include <br />

#include <br />

using namespace std;<br />

int main() {<br />

Stack ac; // Ownership on<br />

Stack ac2(false); // Turn it off<br />

AutoCounter* ap;<br />

for(int i = 0; i < 10; i++) {<br />

ap = AutoCounter::create();<br />

ac.push(ap);<br />

if(i % 2 == 0)<br />

ac2.push(ap);<br />

}<br />

while(ac2)<br />

cout

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

Saved successfully!

Ooh no, something went wrong!