This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: template parameters cannot be friends
- From: "naje" <najeiv at ukr dot net>
- To: "Eljay Love-Jensen" <eljay at adobe dot com>,gcc-help at gcc dot gnu dot org
- Date: Fri, 21 May 2004 18:24:50 +0300
- Subject: Re: template parameters cannot be friends
- Reply-to: "naje" <najeiv at ukr dot net>
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'