OK, here waht i want to do.
i wana make driver,device.. and all those globals so i can use device-> in another file/function.
But i can't seem to understand how to "move" a variable from one file to the other or link 2 files variables.
i'm sure this is very newb question but noone of the tutorials cover that.
[forum request]
why not have a sticky "post minor questions here" thread so that newb questoins don't need a new thread everytime.
very newb question
You can declare them as external, or simple pass the pointer to a function (maybe constructor)...
This is basic C/C++ knowledge, so I suggest you to learn the C/C++ basics !!!
This is basic C/C++ knowledge, so I suggest you to learn the C/C++ basics !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Well, this is basic knowledge, so you really shoul have a look for a C/C++ tutorial first...
anyways, here's a small example:
main.cpp
and this is the header file of the class:
foo.h
Now you can use device and smgr as they where created inside the foo class...
anyways, here's a small example:
main.cpp
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
// this is the class you whant to use
#include "foo.h"
foo myClass;
IrrlichtDevice* device;
ISceneManager* smgr;
int main(){
// here is the initialisation of the engine and main loop...
}
foo.h
Code: Select all
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
class foo{
// here are the declarations of the class members located
};
extern IrrlichtDevice* device;
extern ISceneManager* smgr;
#endif // FOO_H_INCLUDED
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
yea or here:
put this in your global header file:
and then in ONE .cpp file the declaration
put this in your global header file:
Code: Select all
extern irr::irrichtDevice *device;
Code: Select all
irr::irrichtDevice *device = NULL;