Hi i have another username but i cant login!! so i had to create a new account

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....incomplete in the int main and it's missing some functions but i wanted to solve this errors before i keep going

Class.h

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);


};

Class.cpp

#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

#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;
}

errors:

1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(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\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(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\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(18) : error C2784: 'bool std::operator !=(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_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\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(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\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(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\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(18) : error C2676: binary '!=' : 'CNoFila' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(18) : fatal error C1903: unable to recover from previous error(s); stopping compilation

thanks for any help!

Recommended Answers

All 15 Replies

CNoFila is a class... and you are comparing it with operator !=.
But how can it compare your class with NULL?

This comparison only makes sense if you implement operator!= for you CNoFila(Google for 'Operator Overloading') or if 'Actual' is a pointer to CNoFila (a pointer can be NULL).

yes i intended to make Actual a pointer to a CNoFila...

so i changed it and i think that problem is solved but i still encounter some errors:

Simulacao():

void Simulacao(CNoFila &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual = L; 

	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;
			}
		}
	}
}

errors:

1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(17) : error C2440: 'initializing' : cannot convert from 'CNoFila' to 'CNoFila *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(32) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'CNoFila *' (or there is no acceptable conversion)
1> c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\class.h(9): could be 'CNoFila &CNoFila::operator =(const CNoFila &)'
1> while trying to match the argument list '(CNoFila, CNoFila *)'
1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(38) : error C2664: 'Simulacao' : cannot convert parameter 1 from 'CNoFila *' to 'CNoFila &'

update:
i was able to fix more errors!

there is only one left!

here it is the latest function Simulacao():

void Simulacao(CNoFila &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual;
	Actual = &L;

	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;
			}
		}
	}
}

error:

1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(33) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'CNoFila *' (or there is no acceptable conversion)
1> c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\class.h(9): could be 'CNoFila &CNoFila::operator =(const CNoFila &)'
1> while trying to match the argument list '(CNoFila, CNoFila *)'

>> i was able to fix more errors!
Nice.

>> there is only one left!
Even better, I think the error comes from the line #19.
Since Aux and Actual both are of type CNoFila * , I'm guessing that your intention was to write ..

// Set Aux to point to the same CNoFila object as Actual does..
Aux = Actual;

//// instead of
//// *Aux = Actual;

it fixed the error but now i'm getting another one really strange

1>main.obj : error LNK2019: unresolved external symbol "void __cdecl Imprime(int,int,int,int)" (?Imprime@@YAXHHHH@Z) referenced in function "bool __cdecl spot(int,int,int,int &,int,int,int)" (?spot@@YA_NHHHAAHHHH@Z)
1>C:\Users\Tiago\Documents\Visual Studio 2008\Projects\projectoeda\Debug\projectoeda.exe : fatal error LNK1120: 1 unresolved externals

You might re-post your current main.cpp (I don't think these errors match with the above main.cpp). Also you might Rebuild the whole Visual Studio solution and post the errors.

here is the main.cpp

~#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 &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual;
	Actual = &L;

	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, float 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;
}

i rebuild the whole solution and there are the errors

1>main.obj : error LNK2019: unresolved external symbol "void __cdecl Imprime(int,int,int,int)" (?Imprime@@YAXHHHH@Z) referenced in function "bool __cdecl spot(int,int,int,int &,int,int,int)" (?spot@@YA_NHHHAAHHHH@Z)
1>C:\Users\Tiago\Documents\Visual Studio 2008\Projects\projectoeda\Debug\projectoeda.exe : fatal error LNK1120: 1 unresolved externals

OK - you have changed the signature of the Imprime(...) function.

// Your declaration ..
void Imprime(int numerocarro, int numlugar, int situacao, int tempo);
// .. the definition ..
void Imprime(int numerocarro, int numlugar, int situacao, float tempo)

The last parameter has changed from int tempo to float tempo .
Now, you have to decide which way you want to have it and change the code accordingly (i.e. float or int ?). Note that the signatures must match at all times.

Line 12 you declare Imprime as void Imprime(int numerocarro, int numlugar, int situacao, int tempo); then line 93 you define it as

#
void Imprime(int numerocarro, int numlugar, int situacao, float tempo){

.

The type of the last parameter differs which is a mistake. The compiler compiles your code assuming the declaration on line 12 which works because of function overloading and then the linker throughs the error because you have not defined a function like the one declare on line 12.

Fix line 12.

yeah that was the error..


i'm so stupid :S

thank you all

well its stupid but im getting the same error after adding one more function but im pretty positive that it's not like the other one because its declaration and implementation are exactly the same!

main.cpp:

#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 &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual;
	Actual = &L;

	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 tempochegada)
{

	
	CNoFila *Aux = C2.InicioEstac;
	int numlugar;
	int lugaresestac= (2 * (8-n1));
	int lavagemocupado = C1.lugareslavagem();
	int estacocupado = C2.lugaresestacionamento();

	if (lavagemocupado < n1){
		if (estacocupado ==0){
			numlugar = C1.NumLugarLav(n1,*C1.InicioLav);
			C1.InsereItemLav(evento, tempo, numcliente, tempochegada, numlugar);
			
			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, numlugar);
			Imprime(numcliente, numlugar, 1, tempo);
			return 0;
		}
	}

	if (lavagemocupado == n1){
		if (estacocupado < lugaresestac){
			C2.InsereItemEstac(evento, tempo, numcliente, tempochegada, numlugar);
			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;
}

I see no new function in that code.

Surely by now you have learnt when posting to post all the information including errors?

updated main.cpp

with errors(i forgot it before)

Class.h:

class CNoFila{
  public:
	int evento;
	int tempo;
	int numcliente;
	int numlugar;
	int tempochegada;
	CNoFila *Proximo;
};



class CFilaLavagem{
	
  public:
	CNoFila *InicioLav;
    CNoFila *FimLav;
	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 numlugar);
	int NumLugarLav(int n1, CNoFila &L);
	friend void Simulacao(CNoFila &L, 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 numlugar);
	int NumLugarEstac(int n1, CNoFila *InicioEstac);
	friend void Simulacao(CNoFila &L, 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);


};

Class.cpp:

#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->numlugar = L.numlugar;

	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, int numlugar)
{

	CNoFila *Novo = new CNoFila;
	
	Novo->evento =evento;
	Novo->tempo = tempo;
	Novo->tempochegada = tempochegada;
	Novo->numcliente = numcliente;
	Novo->numlugar = numlugar;
	Novo->Proximo=NULL;
	if( InicioLav == NULL ) InicioLav = Novo;  
	else{
		FimLav->Proximo = Novo; 
	}
	
	FimLav = Novo;
}

int NumLugarLav(int n1, CNoFila &L){
	
	
	int tabaux[8];
	CNoFila *Actual;
	Actual = &L;
	int lugar;

	for (int i = 0; i < n1; i++){

		tabaux[i] = Actual->numlugar;
		Actual = Actual->Proximo;
	}
	
	for (int i = 0; i < n1; i++){
		
		if(tabaux[i]==1) continue;
		else { 
			lugar=1;
			break;
		} 
		
		if(tabaux[i]==2) continue;
		else { 
			lugar=2;
			break;
		}

		if(tabaux[i]==3) continue;
		else { 
			lugar=3;
			break;
		}

		if(tabaux[i]==4) continue;
		else { 
			lugar=4;
			break;
		}

		if(tabaux[i]==5) continue;
		else { 
			lugar=5;
			break;
		}

		if(tabaux[i]==6) continue;
		else { 
			lugar=6;
			break;
		}

		if(tabaux[i]==7) continue;
		else { 
			lugar=7;
			break;
		}

		if(tabaux[i]==8) continue;
		else { 
			lugar=8;
			break;
		}
	}
	return lugar;

}

//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, int numlugar) {
	
	CNoFila *Novo = new CNoFila;
	
	Novo->evento = evento;
	Novo->tempo = tempo;
	Novo->tempochegada = tempochegada;
	Novo->numcliente = numcliente;
	Novo->numlugar = numlugar;
	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,CNoFila *InicioEstac){
	
	int tabaux[14];
	
	
	CNoFila *Actual;
	Actual = InicioEstac;

	for (int i = 0; i < 2 * (8-n1); i++){

		tabaux[i] = Actual->numlugar;
		Actual = Actual->Proximo;
	}
	
	for (int i = 0; i < 2 * (8-n1); i++){
		
		if(tabaux[i]!=1) return 1;
		else { 
	
			if(tabaux[i]!=2) return 2;
			else { 
		
				if(tabaux[i]!=3) return 3;
				else { 
			

					if(tabaux[i]!=4) return 4;
					else { 
			
						if(tabaux[i]!=5) return 5;
						else { 
			

							if(tabaux[i]!=6) return 6;
							else { 
							

								if(tabaux[i]!=7) return 7;
								else { 
			

									if(tabaux[i]!=8) return 8;
									else { 
										
										if(tabaux[i]!=9) return 9;
										else { 
											
											if(tabaux[i]!=10) return 10;
											else { 
												
												if(tabaux[i]!=11) return 11;
												else { 
													
													if(tabaux[i]!=12) return 12;
													else { 
															
														if(tabaux[i]!=13) return 13;
														else { 

																if(tabaux[i]!=14) return 14;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}

		
	}
	

}

//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:

#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 &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual;
	Actual = &L;

	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 tempochegada)
{

	
	CNoFila *Aux = C2.InicioEstac;
	int numlugar1, numlugar2;
	int lugaresestac= (2 * (8-n1));
	int lavagemocupado = C1.lugareslavagem();
	int estacocupado = C2.lugaresestacionamento();


	if (lavagemocupado == 0){
		numlugar1 = 1;
		C1.InsereItemLav(evento, tempo, numcliente, tempochegada, numlugar1);
	}
	if ((lavagemocupado < n1) && (lavagemocupado > 0)){
		if (estacocupado ==0){
			numlugar1 = C1.NumLugarLav(n1,*C1.InicioLav);
			C1.InsereItemLav(evento, tempo, numcliente, tempochegada, numlugar1);
			
			Imprime(numcliente, numlugar1, 0, tempo);
			return 1;
		}

		else {
			C1.EstacParaLavagem(*C2.InicioEstac);
			numlugar2 = C2.NumLugarEstac(n1,*C2.InicioEstac);
			numlugar1 = C1.NumLugarLav(n1,*C1.InicioLav);
			Imprime(Aux->numcliente, Aux->numlugar, 3, Aux->tempo);
			
			C2.InsereItemEstac(evento, tempo, numcliente, tempochegada, numlugar2);
			Imprime(numcliente, numlugar2, 1, tempo);
			return 0;
		}
	}

	if (lavagemocupado == n1){
		if (estacocupado < lugaresestac){
			numlugar2 = C2.NumLugarEstac(n1,*C2.InicioEstac);
			C2.InsereItemEstac(evento, tempo, numcliente, tempochegada, numlugar2);
			Imprime(numcliente, numlugar2, 1, tempo);
			return 0;
		}
		
		else{
			carrosout++;
			int numlugar = 0;
			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
	int carrosout;
	Simulacao(*C3.Inicio, t, n1, carrosout, n2);

	cout << "\nO numero de carros que abandonaram sem executar qualquer accao foi: " << carrosout << endl; 

	

	return 0;
}

errors:

1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(73) : error C2664: 'CFilaEstacionamento::NumLugarEstac' : cannot convert parameter 2 from 'CNoFila' to 'CNoFila *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\tiago\documents\visual studio 2008\projects\projectoeda\projectoeda\main.cpp(85) : error C2664: 'CFilaEstacionamento::NumLugarEstac' : cannot convert parameter 2 from 'CNoFila' to 'CNoFila *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

i'm freaking out!!!!

with many tries i fixed the erros....another stupid distraction of me.....

now in linking process it complains about external errors...but this time both declaration and implementatio are exactly the same!!

Class.h:

class CNoFila{ // NÓS.
  public:
	int evento;
	int tempo;
	int numcliente;
	int numlugar;
	int tempochegada;
	CNoFila *Proximo;
};

//===============================================================


class CFilaLavagem{ //CLASSE LUGARES LAVAGEM.
	
  public:
	CNoFila *InicioLav; //Nó Inicial.
    CNoFila *FimLav;	//Nó Final.
	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 numlugar);
	int NumLugarLav(int n1, CNoFila &L);
	friend void Simulacao(CNoFila &L, int &t, int n1, int &carrosout, int n2);
};

//=================================================================


class CFilaEstacionamento{ //CLASSE LUGARES ESTACIONAMENTO.
	
  public:
	CNoFila *InicioEstac;	//Nó Inicial.
    CNoFila *FimEstac;		//Nó Final.
	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 numlugar);
	int NumLugarEstac(int n1,CNoFila &InicioEstac);
	friend void Simulacao(CNoFila &L, int &t, int n1, int &carrosout, int n2);
};

//===============================================================

class CFilaPrincipal{ //CLASSE LUGARES TEMPORÁRIOS.

public:
	CNoFila *Inicio;
    CNoFila *Fim;
	~CFilaPrincipal(void);
	void InsereNoPrincipal(int evento, int numcliente, int tempchegada); //Inserir nós na Fila.
	friend void Simulacao(CNoFila &Actual, int &t, int n1, int &carrosout, int n2);

};

Class.cpp:

#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->numlugar = L.numlugar;

	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, int numlugar)
{

	CNoFila *Novo = new CNoFila;
	
	Novo->evento =evento;
	Novo->tempo = tempo;
	Novo->tempochegada = tempochegada;
	Novo->numcliente = numcliente;
	Novo->numlugar = numlugar;
	Novo->Proximo=NULL;
	if( InicioLav == NULL ) InicioLav = Novo;  
	else{
		FimLav->Proximo = Novo; 
	}
	
	FimLav = Novo;
}

int NumLugarLav(int n1, CNoFila &L){
	
	
	int tabaux[8];
	CNoFila *Actual;
	*Actual = L;
	int lugar;

	for (int i = 0; i < n1; i++){

		tabaux[i] = Actual->numlugar;
		Actual = Actual->Proximo;
	}
	
	for (int i = 0; i < n1; i++){
		
		if(tabaux[i]==1) continue;
		else { 
			lugar=1;
			break;
		} 
		
		if(tabaux[i]==2) continue;
		else { 
			lugar=2;
			break;
		}

		if(tabaux[i]==3) continue;
		else { 
			lugar=3;
			break;
		}

		if(tabaux[i]==4) continue;
		else { 
			lugar=4;
			break;
		}

		if(tabaux[i]==5) continue;
		else { 
			lugar=5;
			break;
		}

		if(tabaux[i]==6) continue;
		else { 
			lugar=6;
			break;
		}

		if(tabaux[i]==7) continue;
		else { 
			lugar=7;
			break;
		}

		if(tabaux[i]==8) continue;
		else { 
			lugar=8;
			break;
		}
	}
	return lugar;

}

//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, int numlugar) {
	
	CNoFila *Novo = new CNoFila;
	
	Novo->evento = evento;
	Novo->tempo = tempo;
	Novo->tempochegada = tempochegada;
	Novo->numcliente = numcliente;
	Novo->numlugar = numlugar;
	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,CNoFila &InicioEstac){
	
	int tabaux[14];
	
	
	CNoFila *Actual;
	Actual = &InicioEstac;

	for (int i = 0; i < 2 * (8-n1); i++){

		tabaux[i] = Actual->numlugar;
		Actual = Actual->Proximo;
	}
	int aux = 1;
	for (int i = 0; i < 2 * (8-n1); i++){
		
		if(tabaux[i]!=aux) return aux;
		else { 
	
			if(tabaux[i]!=aux+1) return aux+1;
			else { 
		
				if(tabaux[i]!=aux+2) return aux+2;
				else { 
			

					if(tabaux[i]!=aux+3) return aux+3;
					else { 
			
						if(tabaux[i]!=aux+4) return aux+4;
						else { 
			

							if(tabaux[i]!=aux+5) return aux+5;
							else { 
							

								if(tabaux[i]!=aux+6) return aux+6;
								else { 
			

									if(tabaux[i]!=aux+7) return aux+7;
									else { 
										
										if(tabaux[i]!=aux+8) return aux+8;
										else { 
											
											if(tabaux[i]!=aux+9) return aux+9;
											else { 
												
												if(tabaux[i]!=aux+10) return aux+10;
												else { 
													
													if(tabaux[i]!=aux+11) return aux+11;
													else { 
															
														if(tabaux[i]!=aux+12) return aux+12;
														else { 

																if(tabaux[i]!=aux+13) return aux+13;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}

		
	}
	

}

//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;
}

CFilaPrincipal::~CFilaPrincipal(void){

	delete this;

}

main.cpp:

#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 &L, int &t, int n1, int &carrosout, int n2)
{
	CNoFila *Actual;
	Actual = &L;

	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 tempochegada)
{

	
	CNoFila *Aux = C2.InicioEstac;
	int numlugar1, numlugar2;
	int lugaresestac= (2 * (8-n1));
	int lavagemocupado = C1.lugareslavagem();
	int estacocupado = C2.lugaresestacionamento();


	if (lavagemocupado == 0){
		numlugar1 = 1;
		C1.InsereItemLav(evento, tempo, numcliente, tempochegada, numlugar1);
		Imprime(numcliente, numlugar1, 0, tempo);
	}
	if ((lavagemocupado < n1) && (lavagemocupado > 0)){
		if (estacocupado ==0){
			numlugar1 = C1.NumLugarLav(n1,*C1.InicioLav);
			C1.InsereItemLav(evento, tempo, numcliente, tempochegada, numlugar1);
			
			Imprime(numcliente, numlugar1, 0, tempo);
			return 1;
		}

		else {
			C1.EstacParaLavagem(*C2.InicioEstac);
			numlugar2 = C2.NumLugarEstac(n1,*C2.InicioEstac);
			numlugar1 = C1.NumLugarLav(n1,*C1.InicioLav);
			Imprime(Aux->numcliente, Aux->numlugar, 3, Aux->tempo);
			
			C2.InsereItemEstac(evento, tempo, numcliente, tempochegada, numlugar2);
			Imprime(numcliente, numlugar2, 1, tempo);
			return 0;
		}
	}

	if (lavagemocupado == n1){
		if (estacocupado < lugaresestac){
			numlugar2 = C2.NumLugarEstac(n1,*C2.InicioEstac);
			C2.InsereItemEstac(evento, tempo, numcliente, tempochegada, numlugar2);
			Imprime(numcliente, numlugar2, 1, tempo);
			return 0;
		}
		
		else{
			carrosout++;
			int numlugar = 0;
			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;
	int carrosout;
	Simulacao(*C3.Inicio, t, n1, carrosout, n2);

	cout << "\nO numero de carros que abandonaram sem executar qualquer accao foi: " << carrosout << endl; 

	

	return 0;
}

errors:
1>main.obj : error LNK2019: unresolved external symbol "bool __cdecl spot(int,int,int,int &,int,int,int)" (?spot@@YA_NHHHAAHHHH@Z) referenced in function "void __cdecl Simulacao(class CNoFila &,int &,int,int &,int)" (?Simulacao@@YAXAAVCNoFila@@AAHH1H@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall CFilaEstacionamento::NumLugarEstac(int,class CNoFila &)" (?NumLugarEstac@CFilaEstacionamento@@QAEHHAAVCNoFila@@@Z) referenced in function "bool __cdecl spot(int,int,int,int &,int,int)" (?spot@@YA_NHHHAAHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall CFilaLavagem::NumLugarLav(int,class CNoFila &)" (?NumLugarLav@CFilaLavagem@@QAEHHAAVCNoFila@@@Z) referenced in function "bool __cdecl spot(int,int,int,int &,int,int)" (?spot@@YA_NHHHAAHHH@Z)
1>C:\Users\Tiago\Documents\Visual Studio 2008\Projects\projectoeda\Debug\projectoeda.exe : fatal error LNK1120: 3 unresolved externals

i checked both functions but i did't find anything connected to this error...

please help :S

i managed to solve the errors


thank you all for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.