GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Oct-2011, 14:22
Rui Jorge Cossa Rui Jorge Cossa is offline
New Member
 
Join Date: Oct 2011
Posts: 3
Rui Jorge Cossa will become famous soon enough

C++ Linker errors


CPP / C++ / C Code:
#include <iostream>
#include "Lista.h"

using namespace std;

//construtor
Lista::Lista()
{
	headEq = NULL;
	headJog = NULL;
	tailEq = NULL;
	tailJog = NULL;
};

//destrutor

Lista::~Lista()
{
	
};

//insere um determinado nó a cauda de uma lista

void Lista::insereEquipa(char nome2[25],char id2[3])
{
	if(headEq == NULL) {
		Equipa *nova = new Equipa;
		nova -> next = NULL;
		nova -> prev = NULL;
		nova -> head = NULL;
		nova -> nome[25] = nome2[25];
		nova -> id[3] = id2[3];
		headEq = nova;
		tailEq = nova;
	}
	else {
		Equipa *nova = new Equipa;
		nova -> nome[25] = nome2[25];
		nova -> id[3] = id2[3];
		nova -> next = NULL;
		nova -> prev = tailEq;
		nova -> head = NULL;
		tailEq = nova;
	}
};


CPP / C++ / C Code:
#include <iostream>
#include "Lista.h"

using namespace std;

//construtor
Lista::Lista()
{
	headEq = NULL;
	headJog = NULL;
	tailEq = NULL;
	tailJog = NULL;
};

//destrutor

Lista::~Lista()
{
	
};

//insere um determinado nó a cauda de uma lista

void Lista::insereEquipa(char nome2[25],char id2[3])
{
	if(headEq == NULL) {
		Equipa *nova = new Equipa;
		nova -> next = NULL;
		nova -> prev = NULL;
		nova -> head = NULL;
		nova -> nome[25] = nome2[25];
		nova -> id[3] = id2[3];
		headEq = nova;
		tailEq = nova;
	}
	else {
		Equipa *nova = new Equipa;
		nova -> nome[25] = nome2[25];
		nova -> id[3] = id2[3];
		nova -> next = NULL;
		nova -> prev = tailEq;
		nova -> head = NULL;
		tailEq = nova;
	}
};


CPP / C++ / C Code:
#include <iostream>
#include "tabDisp.h"

using namespace std;

//onstrutor
tabDisp::tabDisp()
{

};

//desstrutor
tabDisp::~tabDisp()
{

};

//função de dispersão
int tabDisp::funcaoDisp(char id[])
{
	int asc[3];
	int i = 0;
	int valor = 0;
	for(i ; i < 3; i++) {
		asc[i] = id[i];
		valor = valor + asc[i];
	}
	cout << (valor % 4);
	
	return (valor % 4);
};

//inserir elemento
void tabDisp::inserirElemento(char nome[],char id[])
{
	int pos = funcaoDisp(id);
	tabDispe[pos].insereEquipa(nome,id);
};




I get the following error..
i have tried everything

>tabDisp.obj : error LNK2005: "public: __thiscall Lista::Lista(void)" (??0Lista@@QAE@XZ) already defined in Lista.obj
1>tabDisp.obj : error LNK2005: "public: __thiscall Lista::~Lista(void)" (??1Lista@@QAE@XZ) already defined in Lista.obj
1>tabDisp.obj : error LNK2005: "public: void __thiscall Lista::insereEquipa(char * const,char * const)" (?insereEquipa@Lista@@QAEXQAD0@Z) already defined in Lista.obj
1>C:\Users\Rui Jorge\Documents\Visual Studio 2010\Projects\Tabalho Pratico Eda\Debug\Tabalho Pratico Eda.exe : fatal error LNK1169: one or more multiply defined symbols found
  #2  
Old 27-Oct-2011, 14:56
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,148
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: C++ Linker errors


Quote:
Originally Posted by Rui Jorge Cossa
CPP / C++ / C Code:
...
#include "Lista.h"...


CPP / C++ / C Code:
...
#include "Lista.h"...


CPP / C++ / C Code:
...
#include "tabDisp.h"...



error..

>tabDisp.obj : error LNK2005: "public: __thiscall Lista::Lista(void)" (??0Lista@@QAE@XZ) already defined in Lista.obj
1>tabDisp.obj : error LNK2005: "public: __thiscall Lista::~Lista(void)" (??1Lista@@QAE@XZ) already defined in Lista.obj
1>tabDisp.obj : error LNK2005: "public: void __thiscall Lista::insereEquipa(char * const,char * const)" (?insereEquipa@Lista@@QAEXQAD0@Z) already defined in Lista.obj
...multiply defined symbols found

So: How about showing us the infamous "Lista.h" ??? How about "tabDisp.h"


Does either of them have function implementations (or other variable definitions) outside the class definition? Or do you have a separate "Lista.cpp" file? Or what?

What are the names of the files that you posted? Are they separate cpp files in the project? Or what?


Regards,

Dave
__________________
Sometimes I just can't help myself...
  #3  
Old 27-Oct-2011, 23:51
Rui Jorge Cossa Rui Jorge Cossa is offline
New Member
 
Join Date: Oct 2011
Posts: 3
Rui Jorge Cossa will become famous soon enough

Re: C++ Linker errors


Hiii i have solved the problem..
just in case it might help someone

Lista.h:
CPP / C++ / C Code:
#ifndef _H_ListaM
#define _H_ListaM
class Lista
{
	private:
      struct Jogador
            {
              Jogador *next; 
              Jogador *prev;
              int num;
              char id[4];
	          char nome[15];
	          char apelido[15];
	          char pos[2];
           };
           struct Equipa
           {
           	  Equipa *next; 
              Equipa *prev;
	          Jogador *head;
	          char nome[25];
	          char id[3];
           };   
		Equipa *headEq;
		Jogador *headJog;
		Equipa *tailEq;
		Jogador *tailJog;
	public:
		Lista();
		~Lista();
		void insereEquipa(char nome[25],char id[3]);
    };
#endif

tabDisp.h :
CPP / C++ / C Code:

#include "Lista.h"

class tabDisp
{
	private:
		Lista tabDispe[4];

	public:

		tabDisp();
		~tabDisp();
		void inserirElemento(char nome[],char id[]);
		//T removerElemento(T &valor);
		//bool pesquisarElemento(T &valor);
		int funcaoDisp(char id[]);
		//void listarTabelaDisp();
};

My team mate had put #include "Lista.cpp" instead of
#include "Lista.h" on the "tabDisp.h" So it was including "Lista.h" twice ...
Because inside the "Lista.cpp" there is already an #include "Lista.h"

Thank you for your attention
 
 

Recent GIDBlogRunning Linux Programs at Boot Time by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linker Error --Noob aspirant FLTK Forum 7 23-Jun-2011 01:48
Winnt.h errors anandcta1234 MS Visual C++ / MFC Forum 1 13-Apr-2011 07:19
Effective tool for run-time errors and memory leaks detection Jean46 MS Visual C++ / MFC Forum 2 08-Dec-2010 11:13
Wierd errors (again) crystalattice C++ Forum 3 15-Aug-2004 20:02
Can somebody look at this and point out any errors to me soulfly C Programming Language 7 31-Mar-2004 09:45

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:31.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.