What is the difference between public and public

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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

What is the difference between public and public

Post by Asimov »

Hi,

Sorry if the subject is confusing, but I couldn't think of a better way to describe what I want to ask.
I notice in the Eventreciever class the class is defined like this.

Code: Select all

 
class MyEventReceiver : public IEventReceiver
{
public:
<snip>
 
but I have always started classes like this

Code: Select all

class EMissile
{
public:
    EMissile();
<snip>
 
Can you tell me what the part after the : means. I mean public IEventReceiver
Yes I know what public means, but I have never seen it defined like this.
Is it like renaming the class or some kind of psuedo name or something?

I mean you still initialise the class with this
MyEventReceiver receiver;

So I don't understand what the public IEventReceiver is?
juanjpro
Posts: 12
Joined: Mon Nov 24, 2014 12:54 pm

Re: What is the difference between public and public

Post by juanjpro »

That's inheritance: http://www.cplusplus.com/doc/tutorial/i ... nheritance

In Irrlicht you need inheritance so the engine can use your custom event receivers/light managers/etc, otherwise it wouldn't be possible to cast pointers to something Irrlicht recognizes.
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: What is the difference between public and public

Post by Asimov »

Hi juanjpro,

Thankyou I think I understand. I have programmed many things in C++ but never used inheritence. So basically it means MyEventReceiver is inheriting characteristics of the base class IEventReceiver.
I have quickly read about inheritence while I was following c++ tutorials, but never found the need for it in previous projects.

Thank you. I understand now.
Post Reply