it is not really important, but i woul like to know why it dosn't work as intended.
Ist really simpel example (I played a little with typeid operator)
my class:
Code:
---------
template
{
public:
WhatType(const T& at) : ct(at) {}
const char* ausgabe() const;
private:
T ct;
};
---------
Function ausgabe()
Code:
---------
template
{
char c = typeid(T).name()[0];
switch(c)
{
case 'i': return "Integer "; break;
case 'd': return "double "; break;
case 'b': return "bool "; break;
case ('p' || 'P'): return "pointer "; break;
case 'c': return "charakter ";break;
default: return "string ";
}
}
---------
and main():
Code:
---------
int main(int argc, char *argv[])
{
WhatType
cout << wb.ausgabe() << endl;
WhatType
WhatType
cout << wp.ausgabe() << "Orig: " << typeid(pwt).name()[0]<< endl;
WhatType
cout << wi.ausgabe() << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
---------
now I recieve
bool
_string Oring: P_
Integer
Why string?
The case of 'P' or 'p' is pointer and not string!?
Read More...
No comments:
Post a Comment