The choice here is not (only) stylistic: option A provides polymorphism at runtime, while option B provides compile-time polymorphism. You have not provided us with enough information to find out which one is preferable in this case.
In general, my advice would be to use parameter A if and only if you want to call test with A* . This leads to the assumption that A is probably an abstract base class (or at least has virtual functions). In this case, it is unsafe to use option B, and, hopefully, test will consist in calling some virtual functions on A* before the desired effect (unlike dynamic_cast this can be done in unpleasant ways).
However, if you never call test with A* , option B is usually better: you allow the use of a function with any type, and calls to virtual functions have less execution time (which may be insignificant, but nonetheless). It also gives the function a bit more freedom: for example, it can create another TType if necessary, which is more difficult if you pass it a pointer to an abstract base class. Finally, you can use features like specialized patterns and static statements if you really want to.
In general, the question should be "Should I use polymorphism at runtime with this class?"; the choice between the two becomes obvious if you decide this.
(By the way, in the case of a template, you probably want to go through TType const& , not TType const* .)
source share