Page 1 of 1
Pointer problem
Posted: Fri Apr 02, 2004 1:27 pm
by Peter Müller
Hi there.
I've two classes. One has the member IrrlichtDevice *device.
How can the other class use this poiner?
I tried to give the second class this pointer in a parameter, but my compiler said, "Syntaxerror: 'IrrlichtDevice'" in every cpp File, which included the header of the second class
help me, please
Posted: Fri Apr 02, 2004 1:30 pm
by schick
well, hard to tell you a solution, seems to be a c++ syntax problem. Either you post some code here or your compiler with its error message. Maybe you forget the namespace? irr::?
Posted: Fri Apr 02, 2004 1:43 pm
by Peter Müller
I've got the feeling, it's a precompiler error:
Code: Select all
#include <stdio.h>
#include <Irrlicht.h>
using namespace irr;
using namespace video;
class CHeightMap
{
protected:
SHeightMapSize hmsSize;
CHeightPoint hpHeight[16];
public:
CHeightMap(void);
CHeightMap(FILE *HeightMapFile);
~CHeightMap(void);
bool init(FILE *HeightMapFile);
SHeightMapSize getSize(void);
void setSize(SHeightMapSize hmsSize);
CHeightPoint getHeight(int iIndex);
CHeightPoint getHeight(int iX, int iZ);
void drawAll(int iX, int iZ, IrrlichtDevice &device);
//void drawAll(IVideoDriver *driver);
};
You're right, I forgot the namespace, but this wasn't the problem.
Posted: Fri Apr 02, 2004 3:01 pm
by schick
well, post the compiler error message the, why you give a reference of the irrlicht device try to give a pointer.
Posted: Fri Apr 02, 2004 6:45 pm
by Peter Müller
OK, I got it!
Code: Select all
void drawAll(int iX, int iZ, IrrlichtDevice &device);
is wrong
Code: Select all
void drawAll(int iX, int iZ, IrrlichtDevice *device);
is right
@schick:
I didn't post the compiler errors, because they're on german and i didn't know exactly how to translate.
Posted: Mon Apr 05, 2004 12:11 am
by Coolkat
instead of passing it as a variable.. you can make the variable (if it's defined in the class and not a method) a "friend" variable.. if you set the second class to be a "friend" class. but sending it as a param wont hurt. just for future refference.
Posted: Mon Apr 05, 2004 10:51 am
by Peter Müller
Thanks, you're right!