home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13367 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.1 KB  |  45 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!news.mentorg.com!sdl!adk
  3. From: adk@Warren.MENTORG.COM (Ajay Kamdar)
  4. Subject: Re: pointer to member function.
  5. Message-ID: <1992Sep7.180658.8239@Warren.MENTORG.COM>
  6. Organization: Mentor Graphics Corp. - IC Group
  7. References: <1992Sep5.015422.2429@unixland.natick.ma.us>
  8. Date: Mon, 7 Sep 1992 18:06:58 GMT
  9. Lines: 34
  10.  
  11. In article <1992Sep5.015422.2429@unixland.natick.ma.us> dlb@unixland.natick.ma.us (David L. Briggs) writes:
  12. >    A simple question.  If you have a class that has several functions
  13. >with the same name that are overloaded, how can you take the address of one
  14. >of these function?
  15.  
  16. class A {
  17. public:
  18.     int foo(int);
  19.     int foo(char *);
  20.  
  21.     int bar(int);
  22.     int bar(char *);
  23. };
  24.  
  25. main()
  26. {
  27.     int (A::*p1)(int);
  28.     int (A::*p2)(char *);
  29.  
  30.     p1 = &A::foo;    // points to int A::foo(int)
  31.     p2 = &A::foo;    // points to int A::foo(char *)
  32.  
  33.     p1 = &A::bar;    // points to int A::bar(int)
  34.     p2 = &A::bar;    // points to int A::bar(char *)
  35. }
  36.  
  37.  
  38. - Ajay
  39.  
  40. -- 
  41. I speak for none but myself.
  42.  
  43. Ajay Kamdar                               Email : ajay_kamdar@mentorg.com
  44. Mentor Graphics, IC Group (Warren, NJ)    Phone : (908) 580-0102
  45.