Why do I get the error "X is not a member of Y" even though X is a friend of Y?
Posted
by
user1232138
on Stack Overflow
See other posts from Stack Overflow
or by user1232138
Published on 2012-03-26T15:44:49Z
Indexed on
2012/03/29
17:30 UTC
Read the original article
Hit count: 179
I am trying to write a binary tree. Why does the following code report error C2039, "'<<' : is not a member of 'btree<T>'" even though the << operator has been declared as a friend function in the btree class?
#include<iostream>
using namespace std;
template<class T>
class btree
{
public:
friend ostream& operator<<(ostream &,T);
};
template<class T>
ostream& btree<T>::operator<<(ostream &o,T s)
{
o<<s.i<<'\t'<<s.n;
return o;
}
© Stack Overflow or respective owner