So what I am trying to do is implementing the message pattern. And as far as I understand, the user will act upon what message type I put in, not the message type doing the action. Therefore, this is how I approach it:
I want to get the datatype of the object so I can do a switch statement but I am not so sure where to start.
I have looked through google and do some research but none is successful. This is what I have tried:
- Decltype : not even close to what I want
- typeof : I am not so clear about how to use
- dynamic-cast : not close to what I want
Basically, what I want to have at the end is something like this:
switch (typeof(a)) {
class_a : //do something
class_b : //do something
}
An if statement would work the same for me. Can anyone help me out? I would prefer using standard library.
Aucun commentaire:
Enregistrer un commentaire