twl@cs.brown.edu (Ted "Theodore" W. Leung) (03/20/91)
I have a question about friend functions. I have an application where I am simulating a company, where all the employees have a to do list. The only person that can reprioritize an employee's to do list is his manager. I am trying to restrict access to the to-do list to the particular employee subclass and by allowing the manager to have a friend function which can access the representation of the to-do list. I have not been able to get my code to work with a friend function. I have been able to get it to work by declaring Manager as a friend class, but this seems excessive to me. Can someone show me what I am overlooking or explain why a friend function is illegal here A skeletal version of the code as I think it should appear follows below.... class ToDoList { friend Boolean Manager::Reprioritize(Bug& item, int priority); private: ThingList *things; }; class InternalPerson { private: ToDoList ToDo; }; class Manager : public InternalPerson { public: Boolean Reprioritize(Bug& item, int priority); // needs to look at ToDoList }; Thanks in advance, Ted -- -------------------------------------------------------------------- Internet/CSnet: twl@cs.brown.edu | Ted "Theodore" Leung BITNET: twl@BROWNCS.BITNET | Box 1910, Brown University UUCP: uunet!brunix!twl | Providence, RI 02912