Using Templates for Game Object Inheritance

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
Mattonaise
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Mon May 30, 2011 1:55 pm
Favorite Gaming Platforms: PC, iOS
Programming Language of Choice: C++

Using Templates for Game Object Inheritance

Post by Mattonaise »

I've stumbled across this article and it seems kinda interesting:

http://blog.terava.info/past/2011/1/4/g ... ce_in_cpp/

It looks like a cool way to improve object inheritance, but what are your guy's thoughts on it?
User avatar
bnpph
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 75
Joined: Thu Mar 10, 2011 12:30 pm

Re: Using Templates for Game Object Inheritance

Post by bnpph »

I use CRTP all the time - it is very handy.

I prefer it over dynamic inheritance.
Mattonaise
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Mon May 30, 2011 1:55 pm
Favorite Gaming Platforms: PC, iOS
Programming Language of Choice: C++

Re: Using Templates for Game Object Inheritance

Post by Mattonaise »

Im not sure if I'm correct, but it seems like a way to pick and choose your super classes via templates. Is this right?
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Using Templates for Game Object Inheritance

Post by XianForce »

Mattonaise wrote:Im not sure if I'm correct, but it seems like a way to pick and choose your super classes via templates. Is this right?
Yeah, pretty much.

I really enjoyed reading it, and after a few link jumps, and reading through other opinions on different ways to style objects, I'm content with the way I have my own set up. Although I am considering changing the way I have components communicate with each other.
Mattonaise
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Mon May 30, 2011 1:55 pm
Favorite Gaming Platforms: PC, iOS
Programming Language of Choice: C++

Re: Using Templates for Game Object Inheritance

Post by Mattonaise »

Furthermore, it seems like a way to have a sort of "component system", but built at compile time instead of runtime.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Using Templates for Game Object Inheritance

Post by XianForce »

Mattonaise wrote:Furthermore, it seems like a way to have a sort of "component system", but built at compile time instead of runtime.
Yeah, that's essentially what it is. I'm curious as to how different "Mix-Ins" communicate with each other.
Post Reply