Creating a child under a parent type

A

ADT_CLONE

Hello everyone. I'm quite new to this newsgroup and fairly new to C++,
though I have solid knowledge. Basically what I want to do is define a
child in a variable that has a parent type. I am using the Irrlicht
Graphics Engine and it has this function:

Idevice=createDevice(video::EDT_OPENGL,
core::dimension2d<s32>(512, 384), 16, false, false,
false,eventReceiver);

The "eventReceiver" variable has to be of type irr::IEventReceiver*.
Anyway, here is the variable declaration for "eventReceiver":

static Easy_Event_Receiver eventReceiver;

As you can see, there are type issues here, since they are of different
types. Though Easy_Event_Receiver is a child of irr::IEventReceiver* so
isn't it suppose to inherit the type or something. Anyway, I've tried
various things from logical to utterly stupid. I've tried typecasting
though that doesn't work. There must be some way that I can define the
eventReceiver variable with type irr::IEventReceiver* while it still
holds the Easy_Event_Receiver class. Any help would be greatly
appriciated.

ADT_CLONE
 
K

Kai-Uwe Bux

ADT_CLONE said:
Hello everyone. I'm quite new to this newsgroup and fairly new to C++,
though I have solid knowledge. Basically what I want to do is define a
child in a variable that has a parent type. I am using the Irrlicht
Graphics Engine and it has this function:

That library is (like all 3rd party tools) off-topic in this group. Please
read the FAQ for what goes here and where to take questions that don't go
here. You will be rewarded by better answers.
Idevice=createDevice(video::EDT_OPENGL,
core::dimension2d<s32>(512, 384), 16, false, false,
false,eventReceiver);

The "eventReceiver" variable has to be of type irr::IEventReceiver*.
Anyway, here is the variable declaration for "eventReceiver":

static Easy_Event_Receiver eventReceiver;

As you can see, there are type issues here, since they are of different
types. Though Easy_Event_Receiver is a child of irr::IEventReceiver* so
isn't it suppose to inherit the type or something.

One cannot inherit from irr::IEventReceiver* since it is not a class-type.
It's a pointer-to-class type, which is different. Let's assume you meant
that Easy_Event_Receiver inherits from irr:IEventReceiver.
Anyway, I've tried
various things from logical to utterly stupid. I've tried typecasting
though that doesn't work. There must be some way that I can define the
eventReceiver variable with type irr::IEventReceiver* while it still
holds the Easy_Event_Receiver class. Any help would be greatly
appriciated.

Did you try to pass the address of eventReceiver (which would be of type
Easy_Event_Receiver* and should be compatible with irr::IEventReceiver* if
Easy_Event_Receiver inherits from irr:IEventReceiver):

Idevice=createDevice
(video::EDT_OPENGL,
core::dimension2d<s32>(512, 384), 16, false,false,false,
&eventReceiver);
^^^

Note the "&".


Best

Kai-Uwe Bux
 
A

ADT_CLONE

Kai-Uwe Bux said:
That library is (like all 3rd party tools) off-topic in this group. Please
read the FAQ for what goes here and where to take questions that don't go
here. You will be rewarded by better answers.

Yeah, I was just giving a full explanation. It wasn't really the
graphics engine I was having problems with.
One cannot inherit from irr::IEventReceiver* since it is not a class-type.
It's a pointer-to-class type, which is different. Let's assume you meant
that Easy_Event_Receiver inherits from irr:IEventReceiver.

Did you try to pass the address of eventReceiver (which would be of type
Easy_Event_Receiver* and should be compatible with irr::IEventReceiver* if
Easy_Event_Receiver inherits from irr:IEventReceiver):

Idevice=createDevice
(video::EDT_OPENGL,
core::dimension2d<s32>(512, 384), 16, false,false,false,
&eventReceiver);
^^^

Note the "&".

Yeah, I did try that and it didn't work. Though the problem has been
fixed. I just set the variable of type IEventReceiver* and then, under
the contructer, put this:

eventReceiver = new Easy_Event_Receiver();

And it worked fine. Thanks for all the help.

ADT_CLONE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top