I have two classes, Scene and ShaderInfo, and they need to know about each other. To avoid circular includes, I used a forward declaration of ShaderInfo in Scene, but now I'm getting this error:
return type of out-of-line definition of 'Scene::hitObjects' differs from that in the declaration
If I use normal include rather than forward declaration, I get an error saying
error: unknown type name 'ShaderInfo'
from the Scene class. What can I do to make this compile?
error: return type of out-of-line definition of 'Scene::hitObjects' differs from that in the declaration
ShaderInfo Scene::hitObjects(Ray &ray, float &t) {
^
../core/Scene.h:35:13: note: previous declaration is here
ShaderInfo hitObjects(Ray &ray, float &t);
I feel like this is a long shot, but do you have ShaderInfo as a nested class inside Scene as well as outside, so that "ShaderInfo" refers to different classes in each position or something?
Maybe 'ShaderInfo' has a different meaning in the .cpp? If you tell your IDE to take you to the definition, does it take you to the same place from either location?