Original Post
Hi, Occasionaly I read people talking about game entity message passing system. I'm thinking about how to define a message. Most of the messages system define message like this: struct message { int messageid; DWORD var1, DWORD var2 }; Which I think is kind of hacky, since you need to know the actual data type passed in with var1 and var2, and use cast to turn it to the actually type from 'int'. I don't know if there are other solutions around. My thinking is something like this: class messageinterface { int getclassid() = 0; }; class mymessagetype_1 : public messageinterface { int getclassid() {return 1;} int parm1; const char * parm2; }; class mymessagetype_2 : public messageinterface { int getclassid() {return 2;} float parm1; float parm2; float parm3[5]; } Whenever I get a message by a pointer of messgeinterface, I get the classid and then cast the pointer to the actual message class, then I can access the params directly. Are there any drawbacks with this design? My most concern is how much memory footprint this going to take given hundreds of this kind of messages are created. Thanks