Hello i have a problem with includes. The situation is like this:
-Concepts: (NOTE: "....." is to separate the parts of the diagram and make it understable....)
I am designing a program in 3-tier achitecture. The class diagram is like this:
ControladorDomini (domain controller)
| ....... \
Soci .... Abonat
............. |
............. Tarifa
Now, i want to relation Soci and Tarifa to a new class called Servei. The design should be in that way.
So it would be:
ControladorDomini (domain controller)
| ....... \
Soci Abonat
| ....... |
\ ....... Tarifa
\ ....... /
\ ....... /
Serveis
-Code:
ControladorDomini.h
Code:
#ifndef _DOMINI_H_
#define _DOMINI_H_
#include "Abonat.h"
//#include "Servei.h"
#include "Soci.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <vector>
#include <map>
#include "ControladorDades.h"
#include <time.h>
#include <direct.h>
using namespace std;
class ControladorConsola;
class ControladorDades;
class ControladorDomini {
private:
//atributs
ControladorConsola* _cc;
ControladorDades* _cbd;
//ControladorPantalla _cp;
map<int,Abonat> _abonats;//key el num
map<int,Soci> _socis;//key el num
fstream _log;
time_t _tempsLog;
bool _connectat;
bool _estable;
public:
//functions.....
};
#endif
Soci.h
Code:
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include "Servei.h"
using namespace std;
class Soci{
private:
//atributs
int _id;
int _numSoci;
int _llicencia;
string _dni;
string _nom;
string _cognoms;
string _telefon;
string _email;
bool _actiu;
map<int,Servei> _serveis;
public:
//functions....
};
Abonat.h
Code:
#include <iostream>
#include <string>
#include <map>
#include "Tarifa.h"
#include <vector>
using namespace std;
class Abonat{
private:
//atributs
int _id;
int _numAbonat;
string _cif;
string _nom;
string _telefon;
string _email;
string _direccio;
string _poblacio;
string _codiPostal;
bool _actiu;
map<string,Tarifa> _tarifes;
public:
//functions...
};
Tarifa.h
Code:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include "Servei.h"
using namespace std;
class Tarifa {
private:
//atributs
int _id;
string _codi;
float _import;
float _importSoci;
int _idAbonat;
bool _actiu;
map<int,Servei> _serveis;
public:
//functions...
};
I think that the problem is that in ControladorDomini.h, Servei.h is included 2 times: one coming from Soci.h and the other coming from Tarifa.h -> Abonat.h
I need have acces to Servei in Soci and in Tarifa... so i don't know how to solve it....
The compiler error is like this:
Servei.h(7) : error C2011: 'Servei' : nueva definición del tipo 'class'
1> Servei.h(7) : vea la declaración de 'Servei'
The translation:
Servei.h(7) : error C2011: 'Servei' : new definition from type 'class'
1> Servei.h(7) : go to the declaration of 'Servei'
Thank you very much for the help!!!!
Imanol.