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 264 — #302<br />

✐<br />

Capítulo 9. Funciones inline<br />

//: C09:Stack4Test.cpp<br />

//{T} Stack4Test.cpp<br />

#include "Stack4.h"<br />

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

#include <br />

#include <br />

#include <br />

using namespace std;<br />

int main(int argc, char* argv[]) {<br />

requireArgs(argc, 1); // File name is argum<strong>en</strong>t<br />

ifstream in(argv[1]);<br />

assure(in, argv[1]);<br />

Stack textlines;<br />

string line;<br />

// Read file and store lines in the stack:<br />

while(getline(in, line))<br />

textlines.push(new string(line));<br />

// Pop the lines from the stack and print them:<br />

string* s;<br />

while((s = (string*)textlines.pop()) != 0) {<br />

cout

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

Saved successfully!

Ooh no, something went wrong!