[gameprogrammer] Re: How do you make a templated class a friend of a non templated class?

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Thu, 15 Sep 2011 13:35:34 -0700

Thanks Matt, that works! (:

On Thu, Sep 15, 2011 at 10:53 AM, Matthew Weigel <unique@xxxxxxxxxxx> wrote:

> On Wed, 14 Sep 2011 21:38:41 -0700, Alan Wolfe wrote:
>
>  Hey there!
>>
>> I have 2 classes such as below (defined in this order, but they can be
>> reversed if needed)
>>
>> class A
>> {
>> ...
>> };
>>
>> template
>> class B
>> {
>> ...
>> };
>>
>> I need to make friend B a class of friend A but unfortunately i can't
>> find the right syntax.
>>
>> If i put this in class A...
>>
>> friend class B;
>>
>> it gives me a compile error about class B saying "class template has
>> already been declared as a non-class template"
>>
>> If instead, i put this in class A...
>>
>> friend class B<class T>;
>>
>> it gives me a syntax error at the "
>> Does anyone know what the right syntax is? Google isn't helping much.
>>
>
> I think it's:
>
> template<class> friend class B;
>
> --
>  Matthew Weigel
>  hacker
>  unique & idempot . ent
>
> ---------------------
> To unsubscribe go to 
> http://gameprogrammer.com/**mailinglist.html<http://gameprogrammer.com/mailinglist.html>
>
>
>

Other related posts: