I've been trying to seewhat's going on with this program, but can't find anything at all. It compiles but when I execute it nothing appears on the screen.
This is CCentroComercial.h
and this my main programCode:#include <vector> #include <string> using namespace std; class LOJA { public: string nome; string tipo; int renda; }; class CCentroComercial { private: vector<LOJA> lojas; public: void ler_lojas(const char *nome); void imprimir_lojas(ostream &output, const string& tipo); void imprimir_lojas(ostream &output); void ordenarLojas(); };
The content of teste.txt:Code:#include <vector> #include <string> #include <iostream> #include <fstream> #include "CCentroComercial.h" using namespace std; void CCentroComercial::ler_lojas(const char *nome) { ifstream ficheiro; ficheiro.open(nome); while(!ficheiro.get()) { LOJA x; ficheiro >> x.nome >> x.tipo >> x.renda; lojas.push_back(x); } } void CCentroComercial::imprimir_lojas(ostream &output, const string& tipo) { for (int i=0; i<lojas.size(); i++) { if (lojas[i].tipo == tipo) { output << lojas[i].nome << " ; " << lojas[i].tipo << " ; " << lojas[i].renda << endl; } } } void CCentroComercial::imprimir_lojas(ostream &output) { for (int i=0; i<lojas.size(); i++) { output << lojas[i].nome << " ; " << lojas[i].tipo << " ; " << lojas[i].renda << endl; } } int main(int argc, char *argv[]) { char *s = "teste.txt"; CCentroComercial X; X.ler_lojas(s); X.imprimir_lojas(cout); system("PAUSE"); }
MacDonalds
FastFood
1000
Zara
Roupa
5000
As I said, nothing comes up in the screen when I run it. :S



LinkBack URL
About LinkBacks



