c2143 and c4430 errors, help plz!

Nov 10, 2011 at 5:53am
//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.
Nov 10, 2011 at 7:58am
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 Nov 10, 2011 at 8:00am
Nov 10, 2011 at 3:39pm
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.
Nov 10, 2011 at 4:06pm
Thank you very much webJose. circular reference was the problem. My code runs now!
Topic archived. No new replies allowed.