Syntax for declaring a template class as a friend of a non-template class 
Author Message
 Syntax for declaring a template class as a friend of a non-template class

Hello,

I'm attempting to make a template class a friend of a non-template class and
can't figure out what syntax to use to achieve this. Here is a simple bit of
code that won't compile due to a "syntax error : '<end Parse>'" despite the
fact that this is the syntax I found on www.codeproject.com

Anybody have any suggestions?

template <class T>
class TemplateClass
{

public:
    void DoSomething();

protected:
 T m_Obj;

Quote:
};

template <class T>
void TemplateClass<T>::DoSomething()
{
 m_Obj.AccessProtectedInfo();

Quote:
}

class TestClass
{
    template <class T>
        friend class TemplateClass; file://Won't compile!

protected:
 void AccessProtectedInfo() {};

Quote:
};

void
main( char** argv, int argc)
{
    TemplateClass< TestClass > templateClassInstance;
    templateClassInstance.DoSomething();

Quote:
}

Thanks,

Chuck



Thu, 05 Dec 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. friend template class within template class

2. template functions in template classes declared outside the class definition

3. syntax of template method in template class

4. Friend class that is a template class?

5. pb with template function in non template class

6. template member function - non template class - VC5 - error

7. Template function in non-template class

8. Template function in a non-template class

9. Template function in non-template class

10. Class Template problem: The linker can't find my class template

11. Make a template the friend of a class

12. friends in template classes

 

 
Powered by phpBB® Forum Software