Game Development Community

A question for Mark Frohnmeyer.

by David Dougher · in Torque Game Engine · 05/02/2002 (10:23 am) · 2 replies

I was looking at the most recent compiles and I noticed the following warning...

c:\torque_clean\engine\sim\netconnection.cc(194) : warning C4355: 'this' : used in base member initializer list


Being a curious sort I went to the referenced function and saw that the function call was put together like so...

NetConnection::NetConnection(bool ghostFrom, bool ghostTo, bool sendEvents) : mStringTable(this)
{...


Feeling that this might not quite be kosher, I proceeded to check with a couple other programmers I know. The general consensus was that while this may currently work it depends on a very specific compiler interpretation and it may have portability issues with other compilers. I am curious as to why you chose to implement the function in this manner and I wonder if there was a cleaner, safer way that it could have been implemented.

About the author

Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence


#1
05/06/2002 (11:34 am)
Well, I assumed the warning was because the member is constructed before the 'this' object is actually even constructed - for objects that use their construction arguments. The ConnectionStringTable class doesn't use the NetConnection argument in the constructor - it just hangs on to the pointer for later. I could have just added a setConnection() method to ConnectionStringTable and called it from NetConnection's constructor... and maybe I'll do that just to get rid of the warning :)
#2
05/15/2002 (10:07 am)
Thanks for the feedback Mark! Lots to learn and it's nice to see the reasoning of the guys who built the system.