class definition

class Mac802154Packet : public ::MacPacket // what is the meaning of this line?



I want to know what is the meaning of the first line?

The first line should be:
class Mac802154Packet: public MacPacket

It describes and "Is a" relationship, so everything protected and public in MacPacket is inherited by Mac802154Packet. See the documentation in this site.
Last edited on
First line means, that you derive your class Mac802154Packet from the class MacPacket which has a global scope without a namespace (::). The public identifier means, that you have access to all public and protected members implemented in the base class MacPacket.
If MacPacket happens to be in the same name-space with Mac80... that "::" (What's it's name?) would give a compilation error.
Am I right?
ok. But the first line is like that

class Mac802154Packet : public ::MacPacket

what is the function of ( :: ) and ( : ) ?
(::) tells the compiler to look for MacPacket definition in the global namespace instead of local, (:) means "derive from". public means "everything that is public in MacPacket should also be public in Mac8021... and everything that is protected should also be protected in Mac8021..."

So the first line means:
"Derive Mac802154Packet from global MackPacket"

If you used protected instead of public, everything that is public in MacPacket would be protected in Mac8021...

Hope that helps.

Last edited on
Thanks a lot..
i got a link to understand access controls public, private, protected:
Also necessity of protected access specified:

happy learning!
Topic archived. No new replies allowed.