Re: Error:Template as friend class with different arguement list
* neelsmail@rediffmail.com:
This works with MS VS 2003 --->
class B;
class C;
template <class B, class C> class A; //forward declaration
template <class DBT_>
class D {
public:
friend class A<B,C>; //Error as B and C are not known as
template parameters
private :
DBT_ f;
};
This doesn't make the template a friend, it makes the concrete class
A<B,C> a friend. In particular, A<int,int>, the only instantiation used
in the program, is not a friend of D.
template <typename b,typename c>
class A{
private:
typedef D<typename b> myClass;
This is invalid syntax. Use just "b", not "typename b". Even though
MSVC may allow it, "typename" is not a kind spice that you can sprinkle
liberally everywhere in the hope of satisfying the compiler.
Use "typename" to inform the compiler that a dependent name denotes a type.
A dependent name is a name which definition depends on a template
parameter, e.g. Foo<b>::Type.
myClass E;
int j;
};
int func()
{
A<int,int> a;
return 0;
}
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?