W
wongjoekmeu
Hello all,
I have the following problem, maybe someone can help me out.
I have a template class A which has a protected member Aint.
Now I have template class B which has as private member an
instance of A. Now to get the value of Aint I decided to create
a friend function and declare them in both classes. But I cant
get this program to compile as it is complaining about an undeclare
reference. First I was wonderin if with template classes this trick
can be performed with friends function to get access to the protected
member and if anyone could tell me what I am doing wrong.
Thanks in advance.
Robert
int main()
{
GetAint() ;
}
template <class itemType>
class B;
template <class itemType>
class A
{
friend int GetAInt( A<itemType>&);
protected:
int AInt;
}
template <class itemType>
class B
{
friend int GetAInt( A<itemType> & );
private:
A<itemType> myA ;
}
template<class itemType>
int GetAInt(A<itemType> &myA)
{
...
}
I have the following problem, maybe someone can help me out.
I have a template class A which has a protected member Aint.
Now I have template class B which has as private member an
instance of A. Now to get the value of Aint I decided to create
a friend function and declare them in both classes. But I cant
get this program to compile as it is complaining about an undeclare
reference. First I was wonderin if with template classes this trick
can be performed with friends function to get access to the protected
member and if anyone could tell me what I am doing wrong.
Thanks in advance.
Robert
int main()
{
GetAint() ;
}
template <class itemType>
class B;
template <class itemType>
class A
{
friend int GetAInt( A<itemType>&);
protected:
int AInt;
}
template <class itemType>
class B
{
friend int GetAInt( A<itemType> & );
private:
A<itemType> myA ;
}
template<class itemType>
int GetAInt(A<itemType> &myA)
{
...
}