S
Sensei
Hi.
I have a problem with a C++ code I can't resolve, or better, I can't see
what the problem should be!
Here's an excerpt of the incriminated code:
=== bspalgo.cpp
// THAT'S THE BAD FUNCTION!!
void save_bsp_tree( ofstream& of, bsptnodeptr p )
{
if( p->type == bsptnode::CUT ) {
of << (p->cut) << endl;
save_bsp_tree( of, p->below );
save_bsp_tree( of, p->above );
}
else {
if( p->type == bsptnode::IN )
of << "IN" << endl;
else if( p->type == bsptnode::OUT )
of << "OUT" << endl;
else
of << "!UNDEFINED!" << endl;
}
}
=== bsp.cpp
#include "bsp.h"
class bsptnode {
friend class bspt;
public:
enum Type {
CUT = 0x00,
...
};
enum {
UNDEFINED_CUT = unsigned(-1)
};
Type type;
unsigned cut; // <---- HERE'S THE BAD GUY!!
bsptnodeptr below;
bsptnodeptr above;
private:
...
};
=== bsp.h
#include "desf.h"
=== defs.h
typedef bsptnode* bsptnodeptr;
Now, if I compile this, I get:
boolalgo.cpp: In function `void save_bsp_tree(std:fstream&, bsptnode*)':
boolalgo.cpp:67: error: no match for 'operator<<' in 'of <<
p->bsptnode::cut'
PlasmVector.h:143: note: candidates are: std:stream&
operator<<(std:stream&, const PlasmVector&)
matrix.h:96: note: std:stream&
operator<<(std:stream&, const matrix&)
PlasmMatrix.h:69: note: std:stream&
operator<<(std:stream&, const PlasmMatrix&)
PlasmID.h:52: note: std:stream&
operator<<(std:stream&, const PlasmID&)
PlasmHyperPlane.h:168: note: std:stream&
operator<<(std:stream&, const PlasmHyperPlane&)
....
Now, bsptnodeptr is a redefinition of a pointer, and the member in
question is an unsigned... I really can't see what's going wrong. I'm
using gcc 4 under macosx.
I have a problem with a C++ code I can't resolve, or better, I can't see
what the problem should be!
Here's an excerpt of the incriminated code:
=== bspalgo.cpp
// THAT'S THE BAD FUNCTION!!
void save_bsp_tree( ofstream& of, bsptnodeptr p )
{
if( p->type == bsptnode::CUT ) {
of << (p->cut) << endl;
save_bsp_tree( of, p->below );
save_bsp_tree( of, p->above );
}
else {
if( p->type == bsptnode::IN )
of << "IN" << endl;
else if( p->type == bsptnode::OUT )
of << "OUT" << endl;
else
of << "!UNDEFINED!" << endl;
}
}
=== bsp.cpp
#include "bsp.h"
class bsptnode {
friend class bspt;
public:
enum Type {
CUT = 0x00,
...
};
enum {
UNDEFINED_CUT = unsigned(-1)
};
Type type;
unsigned cut; // <---- HERE'S THE BAD GUY!!
bsptnodeptr below;
bsptnodeptr above;
private:
...
};
=== bsp.h
#include "desf.h"
=== defs.h
typedef bsptnode* bsptnodeptr;
Now, if I compile this, I get:
boolalgo.cpp: In function `void save_bsp_tree(std:fstream&, bsptnode*)':
boolalgo.cpp:67: error: no match for 'operator<<' in 'of <<
p->bsptnode::cut'
PlasmVector.h:143: note: candidates are: std:stream&
operator<<(std:stream&, const PlasmVector&)
matrix.h:96: note: std:stream&
operator<<(std:stream&, const matrix&)
PlasmMatrix.h:69: note: std:stream&
operator<<(std:stream&, const PlasmMatrix&)
PlasmID.h:52: note: std:stream&
operator<<(std:stream&, const PlasmID&)
PlasmHyperPlane.h:168: note: std:stream&
operator<<(std:stream&, const PlasmHyperPlane&)
....
Now, bsptnodeptr is a redefinition of a pointer, and the member in
question is an unsigned... I really can't see what's going wrong. I'm
using gcc 4 under macosx.