help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Template parameter as a friend


From: Dmitry Chumack
Subject: Template parameter as a friend
Date: Fri, 01 Jun 2007 09:49:36 -0700
User-agent: G2/1.0

hi *

I have a question, why I can't declare template parameter as a friend?
Here is some example:

//--------------------------------------------------
template <typename T>
class Some
{
    friend class T;

public:

    Some() {}

private:

    T* a;
};

template <typename T>
class Other
{
public:

    Other() {}

private:

    T a;

};


int main()
{
    Some<Other<int> > s;

    return 0;
}
//--------------------------------------------------

When I try to compile it using g++ 3.4.6 I got such an error: "using
typedef-name T after class"
When I change class to typename I get such error: "expected nested-
name-specifier before T", "ISO C++ forbids declaration of `T' with no
type", "`T' is neither function nor member function; cannot be
declared friend"

thanks in advance



reply via email to

[Prev in Thread] Current Thread [Next in Thread]