Wie może ktoś może na czym polega błąd?
Deklaruje funkcję jako zaprzyjaźnioną, ale nie mogę się w niej odwołać do pól prywatnych, nie wiem occ.
#include <iostream>
#include <fstream>
using namespace std;
template <typename T>
class A
{
private:
int _pole;
public:
template <T>
friend ifstream & operator >> (ifstream & ifs, A<T> t);
};
template <typename T>
ifstream & operator >> (ifstream & ifs, A<T> t)
{
t._pole;
return ifs;
}
int main ( )
{
ifstream ifs;
A<int> a;
ifs >> a;
return 0;
}
main.cpp:28:9: instantiated from here
main.cpp:9:7: error: 'int A<int>::_pole' is private
main.cpp:19:2: error: within this context