How to print the return type of a function in Visual Studio 2008 (C++)?
Imagine you 开发者_开发技巧have a function, if you hover over it with the mouse in visual studio you'll get the function prototype. Is it possible to print to the screen the return type of this function ?
This is a practical question, not a programming one. Does the functionality exist in VS ?
I don't know a direct way, but here's a workaround that is relatively easy.
- Right click on the function name.
- Choose either "Go to definition" or "Go to declaration".
- Select/copy the return type using standard copy/paste features.
Why would you want to do this? Is this function a template and you don't know its return type at runtime?
template <typename T>
T dostuff ()
{
//does stuff
cout << typeid(T).name();
return T;
}
精彩评论