This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Templated friends?
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: rguenth at tat dot physik dot uni-tuebingen dot de
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 14 Jan 2003 16:31:01 +0100
- Subject: Re: Templated friends?
Hi,
> template <class X>
> class A {
> void bar() const;
> template <class Y>
> void foo(const A<Y>& a) const {
> a.bar();
> }
> template <class Y>
> friend class A;
> };
>
> int main(int argc, char **argv)
> {
> A<int> a;
> A<double> b;
> a.foo(b);
> return 0;
> }
Your code is ill-formed. "foo" is a private member of "A" and therefore
can be called only inside member functions or friends. But "main" does not
belong to this category. You have to declare "foo" as a public member
to make the code compile.
Regards,
Volker