M
Markus Dehmann
I have a circular dependency between two classes.
The FAQ hint about a forward declaration does not help in my case
([38.11] How can I create two classes that both know about each
other?)
Error: "field `foo' has incomplete type" for the following code:
#include <iostream>
#include <vector>
class FredVector; // forward declaration
class Fred {
public:
FredVector foo;
};
class FredVector : public std::vector<Fred*>{
public:
~FredVector(){ // delete all Fred elements automagically
for (iterator p=begin(); p != end(); ++p)
delete *p;
}
};
If I turn it around and put FredVector before Fred and make a Fred
forward declaration, it results in:
test.cpp: In destructor `FredVector::~FredVector()':
test.cpp:9: Warnung: invalid use of undefined type `struct Fred'
test.cpp:4: Warnung: forward declaration of `struct Fred'
What can I do?
Thanks! Markus
The FAQ hint about a forward declaration does not help in my case
([38.11] How can I create two classes that both know about each
other?)
Error: "field `foo' has incomplete type" for the following code:
#include <iostream>
#include <vector>
class FredVector; // forward declaration
class Fred {
public:
FredVector foo;
};
class FredVector : public std::vector<Fred*>{
public:
~FredVector(){ // delete all Fred elements automagically
for (iterator p=begin(); p != end(); ++p)
delete *p;
}
};
If I turn it around and put FredVector before Fred and make a Fred
forward declaration, it results in:
test.cpp: In destructor `FredVector::~FredVector()':
test.cpp:9: Warnung: invalid use of undefined type `struct Fred'
test.cpp:4: Warnung: forward declaration of `struct Fred'
What can I do?
Thanks! Markus