Can typeid() be used to pass a function?
- by Kerb_z
I tried this and got the output as:
void
Please explain the following Code:
#include <cstdio>
#include <typeinfo>
using namespace std ;
void foo()
{ }
int main(void)
{
printf("%s",
typeid(foo()).name());// Please notice this line, is it same as typeid( ).name() ?
return 0;
}
AFAIK:
The typeid operator allows the type of an object to be determined at run time.
So, does this sample code tell us that a function that returns void is of *type void*.
I mean a function is a method and has no type. Correct?