[Solved] Problem with list

Hello, I have very strange problem. My code looks as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
//#include "zawodnik.h"
#include "gracz.h"
//#include "zdarzenia.h"	
#include "sedzia.h"

int main(){
list<sedzia> naszsedzia;
list<gracz> mojalista;
list<int> inasd;

cout << "AAA";

}


But after compiling it I recieve this:
1
2
3
4
5
test.cpp: In function 'int main()':
test.cpp:7: error: 'sedzia' was not declared in this scope
test.cpp:7: error: template argument 1 is invalid
test.cpp:7: error: template argument 2 is invalid
test.cpp:7: error: invalid type in declaration before ';' token


I have no idea what have might gone wrong. Everything seems to be ok. I compilled each of included files individually and there weren't any errors.

Anybody has any idea?

Robert
Last edited on
Are you sure that 'sedzia' was declared and it isn't in a namespace?
You should check the file sedzia.h
Well, 'sedzia' was deklared and it's not in a namespace.

But look, I switched headers that 'sedzia' was included first and look what happened now:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//#include "zawodnik.h"

//#include "zdarzenia.h"	
#include "sedzia.h"
#include "gracz.h"

int main(){

list<gracz> mojalista;
list<int> inasd;
list<sedzia> naszsedzia;
cout << "AAA";

}


end error:
1
2
3
4
5
test.cpp: In function 'int main()':
test.cpp:9: error: 'gracz' was not declared in this scope
test.cpp:9: error: template argument 1 is invalid
test.cpp:9: error: template argument 2 is invalid
test.cpp:9: error: invalid type in declaration before ';' token


That's so confising...
lets see you "sedzia.h" and "gracz.h" headers, post him
Here you are :).

gracz.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef GRACZ_H
#define GRACZ_H
#include "zawodnik.h"
#include "zdarzenia.h"
#include <list>


class gracz: public zawodnik{
     int iNumberOnTheField;
     string* psPosition;
     list<zdarzenia> events;			//zdarzenia
public:
     gracz();
     gracz(string *, string*, int, int, string*);
     gracz(string,string ,int, int, string);
     ~gracz();
//funkcje get
     int iget_number(){return iNumberOnTheField;}
     string* psget_position(){return psPosition;}
//funkcje set
     void set_number(int);
     void set_position(string);
//funkcja do ustawiania zdarzenia		
     void SetEventForPlayer(int iTemporaryNumber, int iTemporaryTime);
};

#endif 


sedzia.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef GRACZ_H
#define GRACZ_H

#include <string>
#include <iostream>
#include <list>
using namespace std;

enum RefereeKind{
	  MainReferee,
	  Linesman1,
	  Linesman2,
	  Technical,
};

struct RefereeKindAndName{
     RefereeKind eReferee;
     string sName;
};

		    
class sedzia{
     string* Name;
     string* LastName;			//nazwisko ;p
     int age;
     RefereeKind eReferee;
public:
     sedzia();
     sedzia(string *, string*, int, RefereeKind);
     sedzia(string,string ,int, RefereeKind);
     ~sedzia();

     string sGetRefereeKind();
     void sShowReferee();
     friend ostream& operator<<(ostream&, sedzia&);
     
};


#endif 


:)
You have the same #ifndef at the top of both headers, so only the first one will be included. In sedzia.h change it to #ifndef sedzia_h
Thank You very much. That was so lame.... Stupid "copy & paste" common.

Thank You one more time. You saved a lot of my patiance and time.

I own you a beer :).
Topic archived. No new replies allowed.