[comp.windows.ms.programmer] static member functions

oneel@heawk1.gsfc.nasa.gov ( Bruce Oneel ) (05/20/91)

This may be a silly question, but, why is the static needed on member
function a in class test?  I've found this in both g++ as well as
Borland's C++ and I don't understand why from reading the ARM...  The
error message produced when I remove static from the 4th line in g++
is
testcc: In function int main():
test.cc:25: bad argument 0 for functino `test1::b (auto long int
(*)(int))' (type was long in (class test::*)(int))

Thanks in advance for all of your help!!

bruce

This compiles ok.
=================CUT HERE ==================

class test
{
 public:
  static long a (int);
};

class test1
{
 public:
  long b (long (*)(int));
};

long test::a(int i)
{
  return i;
}


test Atest;
test1 Btest;

int main(void)
{

  Btest.b(Atest.a);
  return 0;
}
=================CUT HERE ==================


This doesn't...
=================CUT HERE ==================
class test
{
 public:
  long a (int);
};

class test1
{
 public:
  long b (long (*)(int));
};

long test::a(int i)
{
  return i;
}


test Atest;
test1 Btest;

int main(void)
{

  Btest.b(Atest.a);
  return 0;
}
==============CUT HERE==================

Thanks!!!


bruce
--
Bruce O'Neel              oneel@heasfs.gsfc.nasa.gov
NASA/GSFC/STX/Code 664