Library inclusion issues

I think my program is generating errors due to my library inclusion, can not figure out why.

Here's the header file with the libraries:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include <iostream>
#include <list>
#include <fstream>
#include <string>
#include <iomanip> 
#include <chrono>

using namespace std;

#include "Citoyen.h"
#include "Professionnel.h"
#include "Utilisation.h"
#include "RendezVous.h"
#include "Hospitalisation.h" 


And sample of an error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  class Citoyen
{
protected:
   // Attributs d'un citoyen
   int NAS;
   string nom;
   string naissance;

   // Listes de rendez-vous et d'hospitalisations
   list<RendezVous>listeRendezVous;
   list<Hospitalisation>listeHospitalisations;

[...]

}


In this sample, for line 10, I get:

error C2065: 'RendezVous': undeclared identifier

error C2923: 'std::list': 'RendezVous' is not a valid template type argument for parameter '_Ty'

error C2903: 'allocator': symbol is neither a class template nor a function template

error C3203: 'allocator': unspecialized class template can't be used as a template argument for template parameter '_Alloc', expected a real type
Last edited on
What do you mean by the header file? Do you include that file in every other file?
If so, don't do that. Instead, include headers only where they are needed.
So in Citoyen.h, for instance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string>
#include <list>
#include "RendezVous.h"
#include "Hospitalisation.h"

class Citoyen
{
protected:
   // Attributs d'un citoyen
   int NAS;
   std::string nom;
   std::string naissance;

   // Listes de rendez-vous et d'hospitalisations
   std::list<RendezVous> listeRendezVous;
   std::list<Hospitalisation> listeHospitalisations;

[...]
};


And never use "using namespace std" in a header file. Always explicitly use std:: in header files.

Last edited on
Topic archived. No new replies allowed.