all referencing, no pointers

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
kryton9
Posts: 20
Joined: Sun Feb 22, 2009 7:26 pm

all referencing, no pointers

Post by kryton9 »

I thought this should work from what I read, but I get errors.

How would the proper conversion be done, I am stuck after trying many combinations. I just posted this test, as to the best of my understanding it should work?

Code: Select all

IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,dimension2d<s32>(1024, 768),32,true,false,false);
IrrlichtDevice win = (*device);
IVideoDriver* driver = win.getVideoDriver();
Thanks for any enlightenment.
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

Why would you want to convert a pointer to a reference, especially like that? :shock:

~DtD
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Re: all referencing, no pointers

Post by vitek »

kryton9 wrote:

Code: Select all

IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,dimension2d<s32>(1024, 768),32,true,false,false);
IrrlichtDevice win = (*device);
The code you post is not using a reference. You are attempting to copy an IrrlichtDevice, which, if I'm remembering correctly, is an abstract class and thus cannot be copied in this way.

If you want a reference, you need to tell the compiler that...

Code: Select all

IrrlichtDevice* device_ptr = ...;
IrrlichtDevice& device_ref = *device_ptr;
I don't really understand why you'd want to do this though. It doesn't buy you much of anything. All it does is guarantee that device_ref refers to a non-null object and you get to use the . operator instead of ->.

Travis
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

looks to me like he wants to create a different reference for each OS.

win + directx9 = my assumption.

and yeah I really don't understand what he is going for exactly. looks like something that would require specification and a c++ forum.
kryton9
Posts: 20
Joined: Sun Feb 22, 2009 7:26 pm

Post by kryton9 »

@vitek Thanks. I asked, one to learn and understand after trying everything I could find on the subject from many hours of tinkering.

I have seen libraries that don't have -> and have the . notation and wondered how they pulled it off. DirectX uses pointers and I always wondered how those library writers could write the code.

Thanks again, I will do a search for that syntax to see why I hadn't run across information as valuable as that.

@Midnight and @DtD I can understand why you would wonder why I would ask such a question, but this really helped me tonight.
Post Reply