"Error: Incomplete type is not allowed"

Jun 8, 2012 at 3:21pm
I'm getting this error:

Error: Incomplete type is not allowed


on the following line:

1
2
double horizon_value::test(brain<horizon_value>& B) {
  neuron<horizon_value>* N_back = B.N->back(); // error here, on "B" 


the "brain" type is declared like this:
1
2
3
4
template <typename TTrainer>
struct brain {
  // bunch of stuff
  TTrainer* pT; // points to an instance of "horizon_value" 


I suspect it's because I've made a mess of things by having a function inside horizon_value that takes as input something which is templated to horizon_value. Is there a way around this without fundamentally altering the methodology? Note that if I pass "B" by a pointer I get the same error, except it says that an incomplete pointer type is not allowed...
Jun 8, 2012 at 4:11pm
http://www.cplusplus.com/forum/general/10931/

Did you #include the file where the brain parameterized class (I love saying that) was defined?

Edit: it does seem you may have the problem of:

1) A class depends on B,
2) B class depends on A,
3) they're included in a particular order,
4) one of them doesn't know anything about the other.

You should be able to "fix" this by writing forward declarations.
Last edited on Jun 8, 2012 at 4:18pm
Jun 9, 2012 at 1:12am
Ah right I got it; the problem was that while I did forward-declare brain<TTrainer>, I didn't define it until after I had defined horizon_value (which included the function that calls brain<horizon_value>). Thanks for the help :)
Topic archived. No new replies allowed.