Mitch,
 
Thanks for working out the sample, but that doesn't do what I'm after. As Pai-hung pointed out, what I was trying to do simply isn't possible - as I expected. Try your example with the following modification and you'll see:
 
----8<----
 Template< Derived > t2;
 
 t2.SetPointer( &d );
 t2.CallFoo();
----8<----
 
You can solve this, of course, by making Template< Derived > also a friend (of the Derived class), but that simply is to much fuzz for me... I can live with having the functions I intended to protect being public.
 
Jim Offerman
Innovade.
The Netherlands
----- Original Message -----
From: Mitch Walker
To: 'gdalgorithms-list@lists.sourceforge.net'
Sent: Saturday, December 30, 2000 4:03 AM
Subject: RE: [Algorithms] Template Question...

The attached sample worked for me.  You need a real "type" for the friend access.
 
-Mitch
-----Original Message-----
From: Jim Offerman [mailto:j.offerman@innovade.com]
Sent: Friday, December 29, 2000 6:12 AM
To: gdalgorithms-list@lists.sourceforge.net
Subject: [Algorithms] Template Question...

How do I grant a template access to protected functions of some other class, i.e.
 
template <class cType> class tTemplate
{
public:
   void CallProtectedFunc()
   {
      mType->ProtectedFunc();
   }
protected:
   cType *mType;
};
 
class cObject
{
protected:
   void ProtectedFunc();
 
   friend tTemplate;
};
 
class cDerived : public cObject
{
 
};
 
The above works for instances of cObject, but not for the derived classes, where it generates an compiler error saying that the protected function cannot be accessed.
 
Is there any way around this? Or is the only alternative declaring tTemplate as a friend in all subclasses?
 
Jim Offerman
Innovade.
The Netherlands