Reputation: 1465
I have a rather simple problem
This is my firstcluster.h
#pragma once
#include "cluster.h"
class FirstCluster:public Cluster{
...
public:
...
};
Code for cluster.h:
#pragma once
// File: cluster.h
class Cluster {
protected:
...
public:
...
};
And i'm getting the error:
error C2504: 'Cluster' : base class undefined
Sometimes i get this IntelliSense error:
IntelliSense: incomplete type is not allowed ... Line 10 Column 27
But it doesn't always come up.
The cluster.h
is included, as you can see, and all other header files are protected with #pragma once
I really don't know what could go wrong here?
Can circular include make problems even if i protected everything with #pragma once
?
I'm using Visual Studio 2010.
Upvotes: 7
Views: 14198
Reputation: 1
This error occurs due to circular include so We can handle this by adding the header of child class in the bottom of the parent class
Upvotes: 0
Reputation: 122
I got this due to circular include.
I included all my headers in "include.h" and include it in everywhere else.
I managed to avoid circular include by just including standard headers in include.h.
Upvotes: 7
Reputation: 469
I've had the exact same problem, adding
#ifndef CLUSTER_H
#define CLUSTER_H
/* your code */
#endif
helped to solve the problem. the ifndef part is obviously for include duplications but "define", i think, did help.
Upvotes: 4
Reputation: 2395
This code looks normal, so: if cluster.h actually defines Cluster class, then check for missing namespace around Cluster (if you use a namespace), upper-lower case usage in 'Cluster' vs 'cluster', 'cLuster', etc., also check that the Cluster definition is not local to another class.
Hope this helps.
Upvotes: 2