#problem with inter-dependant classes

9 messages · Page 1 of 1 (latest)

proven olive
#

I have two classes (vec2 and vec3) which rely on each other.
vec2 is declared before vec3 in the header file.
I get this error when attempting to return a vec3 from a function in vec2:

vec.hpp:59:5: error: ‘vec3’ does not name a type; did you mean ‘vec2’?
  59 |     vec3 xxx();
     |     ^~~~
     |     vec2

How can I fix this?

sick larkBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

unkempt elm
#

You can do something like
struct vec3;
Which essential says "there will be a type called vec3 defined sometime later"

proven olive
#

ah

#

thanks, that worked

unkempt elm
#

There are some restrictions with it, but that is step 1

#

Basically if ever you see an error mentioning incomplete types, that is what it refers to

sick larkBOT
#

@proven olive Has your question been resolved? If so, type !solved :)

proven olive
#

!solved