Jump to content
  • Advertisement
Sign in to follow this  
Gf11speed

C# Alternative to Multiple Inheritance

This topic is 3529 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

Since C# does not support multiple inheritance I was wondering if anyone knew a good way to do the following. Basically I have 3 classes, and I'd like to use functionality in class 'PlayerInGame' from both 'Player' and 'SceneNode'. What's the best way to do this? I'd prefer not to include either of those classes IN PlayerInGame if possible. Player SceneNode PlayerInGame : Player, SceneNode Seems like a fairly simple problem, I'm just a C++ programmer having a C# brain freeze tonight. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Well, In C++ I'd recommend that you just change your "is a" relationship to "has a":
struct PlayerInGame
{
Player player;
SceneNode sceneNode;
}

Share this post


Link to post
Share on other sites
This design doesn't make much sense to me. By what logic can something *BE* both a Player and a SceneNode? Maybe a better approach would be the following, if this idea is really given such prominent treatment that it deserves its own type:

SceneNode
PlayerSceneNode : SceneNode ----> has a Player

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!