Pointer problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Pointer problem

Post 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
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
schick
Posts: 230
Joined: Tue Oct 07, 2003 3:55 pm
Location: Germany
Contact:

Post 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::?
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post 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.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
schick
Posts: 230
Joined: Tue Oct 07, 2003 3:55 pm
Location: Germany
Contact:

Post by schick »

well, post the compiler error message the, why you give a reference of the irrlicht device try to give a pointer.
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post 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 :oops:


@schick:
I didn't post the compiler errors, because they're on german and i didn't know exactly how to translate.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Coolkat
Posts: 25
Joined: Sun Mar 28, 2004 1:44 am
Location: U.S.A.

Post 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.
IcePump Gaming
under construction
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Thanks, you're right!
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply