NOTE: This question was originally asked way back in 2012. Before the decltype specifier was fully implemented by any major compilers. You shou
decltype
In C++2003 it can't be done directly but you can delegate to a function template which deduces the type:
template void deduce_member_type(T S::* member) { ... } int main() { deduce_member_type(&Person::age); }