include iostream template class void sample void ptr std cout sizeof s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
template <class T>
void sample (void* ptr)
{
std::cout << sizeof(T) << std::endl;
}
void dummy1 ()
{
sample<char>(NULL);
}
void dummy2 ()
{
sample<int>(NULL);
}
int main(int argc, char* argv[])
{
sample<char>(NULL);
dummy1();
dummy2();
return 0;
}