home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / std / cplus / 1088 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.6 KB  |  49 lines

  1. Path: sparky!uunet!sun-barr!news2me.ebay.sun.com!exodus.Eng.Sun.COM!sun!imagen!iitinc!aaron
  2. From: aaron@iit.com (Aaron Emigh)
  3. Newsgroups: comp.std.c++
  4. Subject: Accessing nested classes from friend functions
  5. Keywords: template class friend
  6. Message-ID: <1992Aug17.230118.1758@iitinc.uucp>
  7. Date: 17 Aug 92 23:01:18 GMT
  8. Sender: aaron@iitinc.uucp (Aaron Emigh)
  9. Reply-To: aaron@iit.com (Aaron Emigh)
  10. Organization: Integrated Information Technology
  11. Lines: 36
  12.  
  13. I was trying to write a friend function of a template class containing
  14. another class taking a pointer to the internal class as an argument, and
  15. couldn't find any way to get my compiler (Borland C++ 3.0) to accept it.
  16. I couldn't find anything clear in my documentation, so I'm wondering if
  17. there is a defined syntax for doing this.
  18.  
  19. In case I'm not being clear, here's an example of what I mean (semantic
  20. content has been reduced to null in the interests of brevity).
  21.  
  22. // A do-nothing template class containing only another class and a
  23. // friend function, for demonstration purposes.
  24.  
  25. template <class type_instance_t>
  26. class class_t {
  27.   class internal_t {
  28.     type_instance_t foo;
  29.   };
  30.   friend void frob_class (internal_t *);
  31. };
  32.  
  33.  
  34. // Here's the question: how do I declare a friend function that takes a
  35. // class nested inside a template class as an argument?
  36.  
  37. template <class type_instance_t>
  38. void frob_class (class_t<type_instance_t>::internal_t *arg)
  39. {
  40. }
  41.  
  42. For my application, declaring internal_t separately and making
  43. class_t its friend works fine, but is less correct in terms of the
  44. operations I am supporting.  Is there a defined way of implementing this
  45. with the class definitions nested?
  46.  
  47. Aaron Emigh
  48. aaron@iit.com
  49.