How can i teach my value type?(Our self method.This is not typeid)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
template<typename Defuse>
Defuse Defuser(Defuse  a){
        int * b;
        char * c;
        float *d;
        if(b=&a)
        printf("This is a int value.\n");
            if(c=&a)
            printf("This is a char value.\n");
            if(d=&a)
        printf("This is a float value.\n");
            
            }
using namespace std;

int main()
{char b='c';
Defuser(b);
system("PAUSE");
    return EXIT_SUCCESS;
}

Can not convert char to int*.How can i do this with another method?
And i think another method.But this is not good.And this is wrong too:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
template<typename Defuse>
Defuse Defuser(Defuse  a){
        if(&a=0x)
        printf("This is a int value.\n");
        if(&a=0xb)
            printf("This is a char value.\n");
            
            }
using namespace std;

int main()
{char b='c';
Defuser(b);
system("PAUSE");
    return EXIT_SUCCESS;
}
Just create three overloads of Defuser(), one for each type. There isn't even a need for a template here.
Topic archived. No new replies allowed.