I have a class Response
say.
#include "NetworkResponse.h"
class NetworkResponse;
class Response {
public:
Response();
virtual ~Response();
Response(NetworkResponse * networkResponse);
NetworkResponses responseCode; // This is an enum and here I get an error
};
#endif
NetworkResponses
is actually an enum defined in the "NetworkResponse.h"
. Like this:
// "NetworkResponse.h":
#include "Response.h"
enum NetworkResponses {
Success = 1,
UserAlreadyExists = 2,
InvalidUsername = 3,
SecurityError = 4,
UnknownError = 5
};
class Response;
class NetworkResponse {
public:
NetworkResponse();
virtual ~NetworkResponse();
};
But I get an error: : "NetworkResponses does not name a type" in the Response
class definition, when I try to compile. Can someone please help?? I think I am missing something simple. I think I was able to use this enum in other classes successfully, don't know what's wrong in this case... Thanks.
You have a cyclic include dependency: NetworkResponse.h
includes Response.h
and vice versa. This cannot work. NetworkResponse.h
does not need to include Response.h
at all, so you can remove that include.
This enum has an underlying type, int in this case. So you can do the following:
int response = Success;
You can use it this way, too. See this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With