🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Dennis Brake Tue, 17 Oct 1995 14:23
Casting Member Function Pointers
#793
Author: Dennis Brake
Date: Tue, 17 Oct 1995 14:23
71 lines
1466 bytes
I'm trying to get the following code to compile with gcc version 2.5.8.
This code has been compiled using both the Sun C++ compiler and the
ObjectStore compiler. The problem occurs in the arguments to the
function "setMbrFcn." The casting to a MbrFcn is required for the other
compilers. Any help or suggestions would be appreciated.

Thanks 
Dennis


atl> gcc -c test.cc
test.cc: In method `Foo::Foo()':
test.cc:34: conversion to non-scalar type requested
test.cc: In method `Bar::Bar()':
test.cc:48: conversion to non-scalar type requested


file: test.cc

class Foo;
typedef void (Foo::*MbrFcn) (void*);

class Foo
{
public:

   Foo ();

protected:

   void setMbrFcn (MbrFcn mbf);
private:

   MbrFcn mbrfcn;
   void fooFunction (void*);
};


class Bar : public Foo
{
public:

   Bar ();

protected:

   void barFunction (void*);
};

Foo::Foo ()
{
   setMbrFcn ((MbrFcn)&Foo::fooFunction);
}

void Foo::setMbrFcn (MbrFcn mbf)
{
   mbrfcn = mbf;
}

void Foo::fooFunction (void*)
{
}

Bar::Bar ()
{
   setMbrFcn ((MbrFcn)&Bar::barFunction);
}

void Bar::barFunction (void*)
{
}
Re: Casting Member Function Pointers
#794
Author: Mike Stump
Date: Tue, 17 Oct 1995 21:43
9 lines
839 bytes
This won't be a problem in the next minor release of g++.

In article <460e8c$8v5@linus.mitre.org>,
Dennis Brake <dbrake@atl.mitre.org> wrote:
>I'm trying to get the following code to compile with gcc version 2.5.8.
>This code has been compiled using both the Sun C++ compiler and the
>ObjectStore compiler. The problem occurs in the arguments to the
>function "setMbrFcn." The casting to a MbrFcn is required for the other
>compilers. Any help or suggestions would be appreciated.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads