home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: pointer to member function.
- Message-ID: <1992Sep5.164303.19876@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Sep5.015422.2429@unixland.natick.ma.us>
- Date: Sat, 5 Sep 1992 16:43:03 GMT
- Lines: 25
-
- dlb@unixland.natick.ma.us (David L. Briggs) writes:
-
- > A simple question. If you have a class that has several functions
- >with the same name that are overloaded, how can you take the address of one
- >of these function?
-
- You have to take the address in a context where the desired function
- type is specified. You normally take the address so as to assign it
- to a pointer-to-member-function, or to pass to a function parameter of
- that type. Type matching resolves the ambiguity if possible.
-
- class X {
- public:
- int foo(int);
- int foo(double);
- int foo(int, int);
- };
-
- int (X::*p1)(int) = &X::foo; // foo(int)
- int (X::*p2)(double) = &X::foo; // foo(double)
- int (X::*p3)(int,int) = &X::foo; // foo(int, int)
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-