So i'm working on a 3D engine at the moment, things are coming along really great.
However i'm stuck at this stupid problem, circular inheritance.
The idea is that i have a terrain of quads obviously, now these quads will be getting a Water object that should be derived from Quad (basically the same, but perhaps 1 or 2 different render states and HLSL vars).
The code below gives me a huge spam of
[code]
Error 1 error C2504: 'Quad' : base class undefined
[/code]
Quad.h
[cpp]
#ifndef QUAD_H
#define QUAD_H
#include "Water.h"
class Quad
{
//Functions and stuff
}
[/cpp]
Water.h
[cpp]
#ifndef WATER_H
#define WATER_H
#include "Quad.h"
class Water : public Quad
{
//Function overrides
};
#endif
[/cpp]
I know this is probably not the best design for this, but it should work best with my quadtree and level of detail and all that.
You're missing a semicolon after the declaration of Quad.
edit:
I didn't notice you were including water.h from quad.h as well, see below
Don't include water.h in quad.h, and just forward declare it with class water;
And then scrap that and rewrite the relevant portions with a better design. Why the hell does a quad (a graphics primitive) need to know about water (a graphics/physics entity)? And why is water inheriting from quad in the first place? That implies an "is-a" relationship. Water isn't a quad. Water might [b]have[/b] a quad ("has a" relationship -> composition) to represent its surface.
[code]
class water
{
private:
quad _surface;
};
[/code]
Your solution would bring me back to the original issue; I want Water to be a Quad but with a slightly edited render loop, so it [i]would[/i] be a Quad.
[QUOTE=Siduron;16704949]Your solution would bring me back to the original issue; I want Water to be a Quad but with a slightly edited render loop, so it [i]would[/i] be a Quad.[/QUOTE]
You can override functions. Is that what you mean?
Yes, but that's not the issue. The problem prevents me to override any functions at all.
[QUOTE=Siduron;16704949]Your solution would bring me back to the original issue; I want Water to be a Quad but with a slightly edited render loop, so it [i]would[/i] be a Quad.[/QUOTE]
Quad doesn't have to know anything about Water for Water to inherit from it.
It includes Water.h for the water object a quad can have.
The Quad should not have a Water object.
I'm going to add another vector to my Patch class, WITH WATER.
Hopefully it will work.
[editline]03:45AM[/editline]
Problem solved.
Instead of giving Quad a Water object, i gave the Patch object a vector with Water objects that are based on the data of another vector with Quads.
Looks awesome, will post a video tomorrow.
I am happy you fixed it. Good job.
As promised, a video.
Unfortunately i had to turn off alpha blending because of a depth issue.
[media]http://www.youtube.com/watch?v=_HfWlV61Lmo[/media]
Sorry, you need to Log In to post a reply to this thread.