J
Jarek Blakarz
Hi
I wonder whether the following program may be treated as example of static
polymorphism. I think yes but I would like to get your opinion here.
thanks
template<typename T>
struct Item
{
void Fun(void) {}
void Fun2(void) {}
};
template<>
struct Item<int>
{
void Fun(void) {}
};
template<>
struct Item<short>
{
void Fun(void) {}
};
template<typename T>
void Fun(Item<T> item)
{
item . Fun();
}
int main(void)
{
Item<int> intType;
Item<short> shortType;
Item<char> charType;
Fun(intType);
Fun(shortType);
Fun(charType);
return 0;
}
I wonder whether the following program may be treated as example of static
polymorphism. I think yes but I would like to get your opinion here.
thanks
template<typename T>
struct Item
{
void Fun(void) {}
void Fun2(void) {}
};
template<>
struct Item<int>
{
void Fun(void) {}
};
template<>
struct Item<short>
{
void Fun(void) {}
};
template<typename T>
void Fun(Item<T> item)
{
item . Fun();
}
int main(void)
{
Item<int> intType;
Item<short> shortType;
Item<char> charType;
Fun(intType);
Fun(shortType);
Fun(charType);
return 0;
}