Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!brunix!doorknob!twl From: twl@cs.brown.edu (Ted "Theodore" W. Leung) Newsgroups: comp.lang.c++ Subject: Friend Functions versus Friend Classes Message-ID: Date: 20 Mar 91 04:11:04 GMT Article-I.D.: boojum.TWL.91Mar19231104 Sender: news@brunix.UUCP Distribution: comp Organization: Department of Computer Science, Brown University Lines: 40 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