Sign in to follow this  
_goat

Something I should know, but don't

Recommended Posts

I have a Quaternion structure, and a Matrix4 structure. They are in different header files, and I would like to have constructors for both that take the other; for example: Quaternion::Quaternion(const Matrix4& matrix), and Matrix4::Matrix4(const Quaternion& q). Obviously, in Matrix4.h, I need to include Quaternion.h, and vice versa. Both files have inclusion guards, of course. However, I'm getting errors because, well, the names aren't resolving. The final real piece of information is that because I have several header files (Vector2, Vector3, ...), I have a header file (atma_math.h), which includes all of them, so only atma_math has to be included when someone wants to do any 3d mathematics. How is the linking (MSVC2005Express) happening, and how do I get it to work? I don't particularly want anyone to suggest different class architecture, because the solution to this problem will let me fix problems like this in the future, unless of course redoing the class architecture is the only way. Cheers.

Share this post


Link to post
Share on other sites
Instead of adding a constructor to each class, try adding a constructor to one of them, and an additional toX() method.

e.g.

Matrix4::Matrix4(const Quaternion& q)
{
...
}

Quaternion Matrix4::toQuaternion() const
{
return Quaternion(...);
}

Share this post


Link to post
Share on other sites
Quote:
I don't particularly want anyone to suggest different class architecture, because the solution to this problem will let me fix problems like this in the future, unless of course redoing the class architecture is the only way.


Edit: Oh yeah, and your method wouldn't work anyway, because the types are still being used inside the header class, which is the problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this