Is it a static polymorphism ?

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;
}
 
J

Jorgen Grahn

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.

It would be interesting to read your motivation for that "yes" first.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top