Article View: gnu.g++.bug
Article #847pointers to member functions
From: Bradley D. Keister
Date: Thu, 20 Aug 1992 10:42
Date: Thu, 20 Aug 1992 10:42
60 lines
1704 bytes
1704 bytes
The following code fragment is taken from a larger file which compiles
and runs correctly under cfront. Under g++ 2.2.2 compilation, I get
ptest.c:22: parse error before `)'
ptest.c:22: `generic' declared as function returning a function
ptest.c:23: parse error before `::'
ptest.c:23: parse error before `)'
ptest.c: In method `double B::A12 (double)':
ptest.c:28: warning: implicit declaration of function `generic'
Here's the code:
---------------
// -*- C++ -*-
class A {
public:
double F1(double x);
double F2(double x);
double F3(double x);
double F4(double x);
};
class B {
protected:
A* a;
public:
B() {a = new A;}
~B() {delete a;}
double generic(double (A::*)(double Qsq),
double (A::*)(double Qsq),
double x);
double A12(double x)
{
return generic(&A::F1, &A::F2, x);
}
double A34(double x)
{
return generic(&A::F3, &A::F4, x);
}
};
Is there a way around this? Am I doing something wrong?
Brad Keister
Department of Physics
Carnegie Mellon University
Pittsburgh, PA 15213
(412) 268-2772 (office)
(412) 681-0648 (FAX)
internet: keister@poincare.phys.cmu.edu
BITNET: keister%poincare.phys.cmu.edu@CARNEGIE
Technical Details
Message-ID:
<9208201842.AA03322@poincare.phys.cmu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keisterShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister From: keister@poincare.phys.cmu.edu (Bradley D. Keister) Subject: pointers to member functions Message-ID: <9208201842.AA03322@poincare.phys.cmu.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 20 Aug 1992 10:42:15 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 61