c2143 and c4430 errors, help plz!

//SnowPark.h
#include <string>
#include "HRManagement.h"
class SnowPark
{
public:
SnowPark(const std::string &n="");
~SnowPark(void);
SnowPark(const SnowPark &s);
std::string getName() const;
void setName(const std::string &n);
void display() const;
private:
std::string name;
};

//HRManagement.h
#include "SnowPark.h"
#include <vector>
#include <string>

class HRManagement
{
public:
HRManagement(void);
~HRManagement(void);

void displayHr() const;

private:
SnowPark *s;
};

The following are the errors i'm getting:
hrmanagement.h(19): error C2143: syntax error : missing ';' before '*'
hrmanagement.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hrmanagement.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Hi guys, I'm new at cpp. Sorry if I made a very silly mistake, but I really dont see any. I checked for a missing ; but as you can see I haven't missed a ; anywhere. I dont understand why the compiler (visual 2010 express) is throwing these errors.

I appreciate any help. Many thanks.
This looks better. always wrap your code.

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
//SnowPark.h
#include <string>
#include "HRManagement.h"
class SnowPark
{
public:
SnowPark(const std::string &n="");
~SnowPark(void);
SnowPark(const SnowPark &s);
std::string getName() const;
void setName(const std::string &n);
void display() const;
private:
std::string name;
};

//HRManagement.h
#include <SnowPark.h>
#include <vector>
#include <string>

class HRManagement
{
public:
HRManagement(void);
~HRManagement(void);

void displayHr() const;

private:
SnowPark *s;
};


Edit: Lol i take it back. not fixed... yet.
Last edited on
You have a circular reference and you are not using header guards (or #pragma once). You need to forward declare one of the classes and avoid the circular reference between the two headers.
Thank you very much webJose. circular reference was the problem. My code runs now!
Topic archived. No new replies allowed.