Re: template parameters cannot be friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Eljay

>#include <iostream>

>class RadioButton
>{
>public:
>     void Draw() const
>     {
>         std::cout<<"radio button"<<std::endl;
>     }
>};

>class TextButton
>{
>public:
>     void Draw() const
>     {
>         std::cout<<"text button"<<std::endl;
>     }
>};

>template<typename T>
>void Draw(T const& t)
>{
>     t.Draw();
>}

>int main()
>{
>     RadioButton rb;
>     Draw(rb);
>     TextButton tb;
>     Draw(tb);
>}
  
but then, i can't make Draw for another superclass,
for example
template<typename T>
Draw(const Window<T>& w)
{
 // do nothing maybe
}

i do not need put method draw in Window's children.

> You cannot have heterogenous collections of static polymorphic objects.

but it's working in older versions of gcc, it's working in gcc 3.3.3 but i can't assert error in compile time, or maybe i don't understand meaning of world 'heterogenous'



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux