Pointers to member funtctions

From: sss (xxx_at_xxx.edu)
Date: 03/29/05


Date: Mon, 28 Mar 2005 14:25:05 -0800

Consider the followning.
int main(){
  int (*move)();
  int (*mve)(int);
  int temp();
  int temp(int);

  move = temp;
  move = &temp;

  mve = temp;
  mve = &temp;
}

The compiler does not seem to have any complaints on the above lines.
But when I change the everything to being part of a class it no longer
works.

class xxxx{
  int (*move)();
  int (*mve)(int);
  int temp();
  int temp(int);
  xxxx();
};

xxxx::xxxx(){
  move = temp;
  move = &temp;

  mve = temp;
  mve = &temp;
}

Anybody know why the second approach does not work.



Relevant Pages

  • Re: Saving data
    ... if you tell your compiler to conform to a C standard it is required to produce at least one diagnostic. ... char char1; ... fwrite (temp, 1, 1, fp); ...
    (comp.lang.c)
  • Re: Converting code from single to double precision
    ... int VarHasData; ... void PrintFortranLine (char *s); ... int continuedFormat = FALSE; ... char temp; ...
    (comp.lang.fortran)
  • Re: In which scope should variables be declared?
    ... > specific scope I can. ... > int foo ... > imagine that temp could be a huge array or max could be a large number. ... > this is a compiler issue, but I am not sure how much the standards ...
    (comp.lang.c)
  • Re: Optimization Level -O2 in gcc
    ... int f3nPlus1; ... if (temp> maximumCycle) { ... You're not returning a value from f3nPlus1, ... input errors for you, but you're throwing away that information. ...
    (comp.lang.c)
  • Re: Optimization Level -O2 in gcc
    ... int f3nPlus1; ... if (temp> maximumCycle) { ... You're not returning a value from f3nPlus1, ... input errors for you, but you're throwing away that information. ...
    (comp.lang.c)