0

I have the following declaration:

friend ostream& operator<<(ostream&,const List&);

and I have the following definition:

ostream& operator<<(ostream& out,const List& item) {
    vector<List::Employee>::const_iterator It;
    for (It=item.employees.begin();It!=item.employees.end();It++) {}
}

Employee is a structure of mine own,and employees is a private vector of Employee in class List. The compiler gives me the following errors:

std::vector<List::Employee,std::allocator<List::Employee>> List::employees is private

any ideas how to solve it?

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
Qiaosen Huang
  • 1,093
  • 1
  • 10
  • 25

1 Answers1

0

The friend declaration should be inside the List class definition.

class List{
    ...
    friend ostream& operator<<(ostream&,const List&);
};
zen-cat
  • 425
  • 2
  • 9