Hi, i'm doing a project in Visual C++....in Portuguese....i 'm hoping you can help figure out the problem eventhough it's not in english...
here is the whole code....incompl ete in the int main and it's missing some functions but i wanted to solve this errors before i keep going
Class.h
Class.cpp:
main.cpp:
these are the errors:
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::istreambuf _iterator<_Elem ,_Traits> &,const std::istreambuf _iterator<_Elem ,_Traits> &)' : could not deduce template argument for 'const std::istreambuf _iterator<_Elem ,_Traits> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ streambuf(557) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::allocator< _Ty> &,const std::allocator< _Other> &) throw()' : could not deduce template argument for 'const std::allocator< _Ty> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xmemory(180) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::reverse_it erator<_RanIt> &,const std::reverse_it erator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_it erator<_RanIt> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xutility(2254) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::_Revranit< _RanIt,_Base> &,const std::_Revranit< _RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit< _RanIt,_Base> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xutility(2061) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::pair<_Ty1, _Ty2> &,const std::pair<_Ty1, _Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1, _Ty2> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ utility(91) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2676: binary '!=' : 'CNoFila' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Can anyone help me fix this errors??
thanks for any help
here is the whole code....incompl ete in the int main and it's missing some functions but i wanted to solve this errors before i keep going
Class.h
Code:
class CNoFila{ public: int evento; int tempo; int numcliente; int numlugar; int tempochegada; CNoFila *Proximo; }; class CFilaLavagem{ CNoFila *InicioLav; CNoFila *FimLav; public: CFilaLavagem(void); //constructor por defeito ~CFilaLavagem(void); //Destructor friend class CFilaEstacionamento; void ApagaItemLav(int numcliente); int lugareslavagem(void); friend bool spot(int n1, int tempo, int evento, int &carrosout, int numcliente, int numlugar, int tempochegada); void EstacParaLavagem(CNoFila &L); void InsereItemLav(int evento, int tempo, int numcliente, int tempochegada); int NumLugarLav(int n1); friend void Simulacao(CNoFila &Actual, int &t, int n1, int &carrosout, int n2); }; class CFilaEstacionamento{ public: CNoFila *InicioEstac; CNoFila *FimEstac; CFilaEstacionamento(); //constructor por defeito CFilaEstacionamento(const CNoFila & L); ~CFilaEstacionamento(void); //Destructor void ApagaItemEstac(void); int lugaresestacionamento(void); friend bool spot(int n1, int tempo, int evento, int &carrosout, int numcliente, int numlugar, int tempochegada); friend class CFilaLavagem; void InsereItemEstac(int evento, int tempo, int numcliente, int tempochegada); int NumLugarEstac(int n1); friend void Simulacao(CNoFila &Actual, int &t, int n1, int &carrosout, int n2); }; class CFilaPrincipal{ public: CNoFila *Inicio; CNoFila *Fim; void InsereNoPrincipal(int evento, int numcliente, int tempchegada); friend void Simulacao(CNoFila &Actual, int &t, int n1, int &carrosout, int n2); };
Code:
#include <iostream> #include "Class.h" //CFilaLavagem void CFilaLavagem::ApagaItemLav(int numcliente) { CNoFila *Actual = InicioLav; CNoFila *Anterior; if (InicioLav == NULL) return; else{ while(Actual!=NULL){ if(Actual->numcliente == numcliente){ if(Anterior ==NULL){ InicioLav = Actual->Proximo; } else{ Anterior->Proximo = Actual->Proximo; } delete (Actual); return; } Anterior = Actual; Actual=Actual->Proximo; } if (InicioLav ==NULL) FimLav = NULL; } } CFilaLavagem::CFilaLavagem(void) { InicioLav = FimLav = NULL; } CFilaLavagem::~CFilaLavagem(void) { delete this; } int CFilaLavagem::lugareslavagem(void) { int lavagem = 0; CNoFila *Actual = InicioLav; if (Actual==NULL) return 0; else{ while(Actual!=NULL) { lavagem++; Actual = Actual->Proximo; } } return (lavagem); } void CFilaLavagem::EstacParaLavagem(CNoFila &L) { CNoFila *Novo = new CNoFila; Novo->evento = L.evento; Novo->tempo = L.tempo; Novo->tempochegada = L.tempochegada; Novo->numcliente = L.numcliente; Novo->Proximo=NULL; if( InicioLav == NULL ) InicioLav = Novo; else{ FimLav->Proximo = Novo; } FimLav = Novo; } void CFilaLavagem::InsereItemLav(int evento, int tempo,int numcliente, int tempochegada) { CNoFila *Novo = new CNoFila; Novo->evento =evento; Novo->tempo = tempo; Novo->tempochegada = tempochegada; Novo->numcliente = numcliente; Novo->Proximo=NULL; if( InicioLav == NULL ) InicioLav = Novo; else{ FimLav->Proximo = Novo; } FimLav = Novo; } int NumLugarLav(int n1){ int numlugar; return numlugar; } //CFilaEstacionamento CFilaEstacionamento::~CFilaEstacionamento() { delete this; } CFilaEstacionamento::CFilaEstacionamento() { InicioEstac = FimEstac = NULL; } int CFilaEstacionamento::lugaresestacionamento(void) { int estac = 0; CNoFila *Actual = InicioEstac; if (Actual==NULL) return 0; else{ while(Actual!=NULL) { estac++; Actual = Actual->Proximo; } } return (estac); } void CFilaEstacionamento::InsereItemEstac(int evento, int tempo, int numcliente, int tempochegada) { CNoFila *Novo = new CNoFila; Novo->evento = evento; Novo->tempo = tempo; Novo->tempochegada = tempochegada; Novo->numcliente = numcliente; Novo->Proximo=NULL; if( InicioEstac == NULL ) InicioEstac = Novo; else{ FimEstac->Proximo = Novo; } FimEstac = Novo; } void CFilaEstacionamento::ApagaItemEstac(void) { CNoFila *Aux; if (InicioEstac == NULL) return; else{ Aux = InicioEstac; InicioEstac = Aux->Proximo; delete Aux; if (InicioEstac ==NULL) FimEstac = NULL; } } int NumLugarEstac(int n1){ int numlugar; return numlugar; } //CFilaPrincipal void CFilaPrincipal::InsereNoPrincipal(int evento, int numcliente, int tempochegada){ CNoFila *Novo = new CNoFila; Novo->evento = evento; Novo->tempochegada = tempochegada; Novo->numcliente = numcliente; Novo->Proximo=NULL; if( Inicio == NULL ) Inicio = Novo; else{ Fim->Proximo = Novo; } Fim = Novo; }
main.cpp:
Code:
#include <iostream> #include "Class.h" #include <fstream> CFilaLavagem C1; CFilaEstacionamento C2; CFilaPrincipal C3; using namespace std; void Imprime(int numerocarro, int numlugar, int situacao, int tempo); void Simulacao(CNoFila &Actual, int &t, int n1, int &carrosout, int n2) { while( (Actual != NULL) && (t < n2)){ CNoFila *Aux; cout << "Chegada de um carro"; for (int i = 0; i < Actual.tempochegada; i++){ } t = t + Actual.tempochegada; //falta determinar lugar memo bool lugar = spot(n1, Actual.tempo, Actual.evento, carrosout, Actual.numcliente, Actual.numlugar, Actual.tempochegada); *Aux = Actual; if (lugar == 1){ for (int j = 0; j < Aux->tempo; j++){ Actual = Actual.Proximo; Simulacao(Actual, t, n1, carrosout, n2); t +=Aux->tempo; } } } } bool spot(int n1, int tempo, int evento, int &carrosout, int numcliente, int numlugar, int tempochegada) { CNoFila *Aux = C2.InicioEstac; int lugaresestac= 2 * (8-n1); int lavagemocupado = C1.lugareslavagem(); int estacocupado = C2.lugaresestacionamento(); if (lavagemocupado < n1){ if (estacocupado ==0){ C1.InsereItemLav(evento, tempo, numcliente, tempochegada); Imprime(numcliente, numlugar, 0, tempo); return 1; } else { C1.EstacParaLavagem(*C2.InicioEstac); Imprime(Aux->numcliente, Aux->numlugar, 3, Aux->tempo); C2.InsereItemEstac(evento, tempo, numcliente, tempochegada); Imprime(numcliente, numlugar, 1, tempo); return 0; } } if (lavagemocupado == n1){ if (estacocupado < lugaresestac){ C2.InsereItemEstac(evento, tempo, numcliente, tempochegada); Imprime(numcliente, numlugar, 1, tempo); return 0; } else{ carrosout++; Imprime(numcliente, numlugar, 2, tempo); return 0; } } return 0; } void Imprime(int numerocarro, int numlugar, int situacao, int tempo){ float hora = tempo/3600; float minuto = (hora - (int)hora)*60; float segundo = (minuto - (int)minuto)*60; ofstream fout; fout.open("Registo.txt"); switch (situacao){ case 0: fout << hora << ":" << minuto << ":" << segundo << " - Chegada de um novo cliente (#" << numerocarro << "). Ocupa o lugar de lavagem #" << numlugar << ". Executa a opcao escolhida." << endl; break; case 1: fout << hora << ":" << minuto << ":" << segundo << " - Chegada de um novo cliente (#" << numerocarro << "). Ocupa o lugar de estacionamento #" << numlugar << ". Aguarda a sua vez." << endl; break; case 2: fout << hora << ":" << minuto << ":" << segundo << " - Chegada de um novo cliente (#" << numerocarro << "). Os lugares estao todos ocupados e o carro vai-se embora" << endl; break; case 3: fout << hora << ":" << minuto << ":" << segundo << " - O cliente #" << numerocarro << " que se encontrava no estacionamento desloca-se para o lugar de lavagem #" << numlugar << endl; } fout.close(); } int TempoEvento(int evento, int n4, int m4, int n5, int m5, int n6, int m6){ int tempototal; if (evento == 1){ tempototal = (rand()%(n4+m4+1)) + (n4-m4-2); } if (evento == 2){ tempototal = ((rand()%(n5+m5+1)) + (n5-m5-2))+((rand()%(n4+m4+1)) + (n4-m4-2)); } if (evento == 3){ tempototal = ((rand()%(n6+m6+1)) + (n6-m6-2)) + ((rand()%(n5+m5+1)) + (n5-m5-2))+((rand()%(n4+m4+1)) + (n4-m4-2)); } return tempototal; } int main() { //DECLARAÇÃO CNoFila *Actual; int n3, m3, n4, m4, n5, m5, n6, m6; int n1,n2, numtotalclientes, numcliente = 1; //======================================================= //VALORES PEDIDOS AO UTILIZADOR do{ cout << "Introduza o numero de zonas de lavagem a simular(1 a 8): "; cin >> n1; }while(1 > n1 && n1 > 8); do{ cout << "Introduza tempo TOTAL de simulacao: "; cin >> n2; }while(1 > n2); do{ cout << "Introduza valores de n3 e m3 (INTERVALO-chegada de novo cliente): "; cout<< "n3:"; cin >> n3; cout<< "m3:"; cin >> m3; }while(1 > n3 && m3 < 1); do{ cout << "Introduza valores de n4 e m4 (INTERVALO-lavagem do carro): "; cout<< "n4:"; cin >> n4; cout<< "m4:"; cin >> m4; }while(1 > n4 && m4 < 1); do{ cout << "Introduza valores de n5 e m5 (INTERVALO-aspiração do carro): "; cout<< "n5:"; cin >> n5; cout<< "m5:"; cin >> m5; }while(1 > n5 && m5 < 1); do{ cout << "Introduza valores de n5 e m5 (INTERVALO-polimento do carro): "; cout<< "n6:"; cin >> n6; cout<< "m6:"; cin >> m6; }while(1 > n6 && m6 < 1); cout << "\nO numero total de lugares de estacionamento e': " << 2 * (8-n1) << endl; cout << "Introduza o numero total de clientes do estabelecimento: "; cin >> numtotalclientes; //=========================================================== for( int i=0; i < numtotalclientes; i++){ int evento = rand()% 2; evento++; int tempchegada = (rand()%(n3+m3+1)) + (n3-m3-2); C3.InsereNoPrincipal(evento, numcliente, tempchegada); numcliente++; } //=========================================================== for(int j = 0; j < numtotalclientes; j++){ Actual = C3.Inicio; int t2 = TempoEvento(Actual->evento, n4, m4, n5, m5, n6, m6); Actual->tempo = t2; Actual = Actual->Proximo; } cout << "Comecando a Simulacao!" << endl; int t = 0;// memo return 0; }
these are the errors:
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::istreambuf _iterator<_Elem ,_Traits> &,const std::istreambuf _iterator<_Elem ,_Traits> &)' : could not deduce template argument for 'const std::istreambuf _iterator<_Elem ,_Traits> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ streambuf(557) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::allocator< _Ty> &,const std::allocator< _Other> &) throw()' : could not deduce template argument for 'const std::allocator< _Ty> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xmemory(180) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::reverse_it erator<_RanIt> &,const std::reverse_it erator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_it erator<_RanIt> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xutility(2254) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::_Revranit< _RanIt,_Base> &,const std::_Revranit< _RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit< _RanIt,_Base> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ xutility(2061) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2784: 'bool std::operator !=(const std::pair<_Ty1, _Ty2> &,const std::pair<_Ty1, _Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1, _Ty2> &' from 'CNoFila'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ utility(91) : see declaration of 'std::operator !='
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : error C2676: binary '!=' : 'CNoFila' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\users\tiag o\documents\vis ual studio 2008\projects\p rojectoeda\proj ectoeda\main.cp p(18) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Can anyone help me fix this errors??
thanks for any help
Comment