home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18970 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.2 KB  |  47 lines

  1. Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!sdcc12!sdcc8!cs163wav
  2. From: cs163wav@sdcc8.ucsd.edu (Anthony Minkoff)
  3. Newsgroups: comp.lang.c++
  4. Subject: HELP: How to typedef for private members?
  5. Message-ID: <43348@sdcc12.ucsd.edu>
  6. Date: 11 Jan 93 23:25:22 GMT
  7. Sender: news@sdcc12.ucsd.edu
  8. Organization: University of California, San Diego
  9. Lines: 35
  10. Nntp-Posting-Host: sdcc8.ucsd.edu
  11.  
  12.  
  13. I need to define a class with private members that are types created
  14. for this class.  Since they are only needed for the class, the user
  15. should not know about them.  E.g.:
  16.  
  17. class Foo {
  18.  
  19.     public:
  20.  
  21.         Foo ( );
  22.         ~Foo ( );
  23.         /* etc */
  24.  
  25.     private:
  26.  
  27.         typedef struct {
  28.             int one;
  29.             int two;
  30.         } two_ints;
  31.  
  32.         two_ints a;
  33.  
  34. } ;
  35.  
  36. The problem with the above code is that when I #include this header
  37. in a program, the program knows about the two_ints type.  Is there
  38. any way to hide this type definition?
  39.  
  40. An example of this situation might be a LinkedList class.  The
  41. LinkedList class might use a node struct or class, but users of the
  42. LinkedList class would not need to know about or use nodes directly.
  43.  
  44. Reponses in e-mail, please.
  45.  
  46. Tony
  47.