[TriLUG] OT: C++ Question

Tanner Lovelace clubjuggler at gmail.com
Tue Jan 31 10:30:53 EST 2006


On 1/31/06, Randy Barlow <rpbarlow at ncsu.edu> wrote:
>  Thanks Brian (and Tanner!)  This was definitely an issue in my code, but
> I'm still having problems with the vector3d identifier in my point3d.h file.
>  Here is point3d.h:
>
>  #pragma once
>  #include "vector3d.h"

[...snip...]

> line in the code above.  Here is vector3d.h:
>
>  #pragma once
>  #include "point3d.h"

There's your problems.  You've told the compiler to only include
things once and then gone and included them in each other.
That's most definitely *not* going to work because, although
the #pragma stops the infinite recursion of includes, you reference
them from each class so one of the classes will be defined before
the other and won't know anything about the other.  You could try
adding a forward declaration, but I really think you should just
bit the bullet and rethink your code.

Cheers,
Tanner

--
Tanner Lovelace
clubjuggler at gmail dot com
http://wtl.wayfarer.org/
(fieldless) In fess two roundels in pale, a billet fesswise and an
increscent, all sable.



More information about the TriLUG mailing list