Jump to content
  • Advertisement
Sign in to follow this  
ratha

Doubt in C++ Inheritance

This topic is 2567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!
I've to maintain somebody's code. There is a derivation like the following:


class TSession: public IServer, public m_object::TObject


What's the meaning of:

public m_object::TObject

What's the difference between

class TSession: public IServer


and


class TSession:public m_object::TObject

Share this post


Link to post
Share on other sites
Advertisement
It's C++ multiple inheritance (google the last three words for more information)

But from the class prefix, it's that,
1, TSession inherits from TObject
2, TSession implements the interface IServer

It's better to write interface after parent class,
class TSession: public m_object::TObject, public IServer

Share this post


Link to post
Share on other sites

It's C++ multiple inheritance (google the last three words for more information)

But from the class prefix, it's that,
1, TSession inherits from TObject
2, TSession implements the interface IServer

It's better to write interface after parent class,
class TSession: public m_object::TObject, public IServer


It should be noted that C++ doesn't have such a thing as an "interface", this is only emulated by an abstract class that, by common convention, that has a 0 implementation for all of its functions (all of which are virtual) and no data members.

Share this post


Link to post
Share on other sites

It's C++ multiple inheritance (google the last three words for more information)

But from the class prefix, it's that,
1, TSession inherits from TObject
2, TSession implements the interface IServer

It's better to write interface after parent class,
class TSession: public m_object::TObject, public IServer


Sorry. I actually asked a different question than what I thought to ask. I know Multiple inheritance. What's the difference between

class TSession: public m_object::TObject

and

class TSession: public TObject

Why "m_object::TObject" is used instead of "TObject"? I saw and practiced like the later(mear "TObject").
That's why I asked the significance of "m_object::TObject"?

Share this post


Link to post
Share on other sites
m_object::TObject is a kind of very weird style according to the name m_object.
You should check the declaration of m_object.
It should be a class, structure, or,..., namespace.

m_object::TObject means a type TObject in a scope named TObject (class, namespace, whatever).


class m_object {
public:
class TObject {
// blah blah
};
};


Edited: Does m_object mean meta object in your code style? :rolleyes:

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!