🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #38366

Re: C++ and callbacks

#38366
From: Eric Gunnerson
Date: Mon, 02 May 1994 19:36
19 lines
1538 bytes
pauld@verdix.com (Paul Durbin) writes:

>I attempt to use a member function as callback but all three arguments (to the
>callback) are garbage. If I make it a friend then the arguments are correct,
>but then I can't get to the class data, without reference thru an instance of
>the class and I don't want the data to be static.

>So, what is causing this problem? Could I possibly use the *this pointer as
>the client_data to the callback, then cast to the appropriate class?

All non-static member functions have an invisible 'this' pointer as
their first parameter. That's what's causing your problems.

Declare a static member function and use that as the callback function.
Passing the this pointer and casting it to the appropriate class works
fine.
--
Eric Gunnerson
gunnerso@halcyon.com
Technical Details
Message-ID: <2q3kon$c01@nwfocus.wa.com>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!nwnexus!coho!gunnerso
References: <pauld.767898877@sarge>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,ad5a39011a2d3d26
X-Google-Attributes: gid109fba,public
X-Google-Thread: 103734,ad5a39011a2d3d26
X-Google-Attributes: gid103734,public
X-Google-Thread: 10ba33,ad5a39011a2d3d26
X-Google-Attributes: gid10ba33,public
X-Google-ArrivalTime: 1994-05-02 14:04:52 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!nwnexus!coho!gunnerso
From: gunnerso@coho.halcyon.com (Eric Gunnerson)
Newsgroups: comp.windows.x,comp.lang.c++,gnu.g++.help
Subject: Re: C++ and callbacks
Date: 2 May 1994 19:36:55 GMT
Organization: Northwest Nexus Inc.
Lines: 19
Message-ID: <2q3kon$c01@nwfocus.wa.com>
References: <pauld.767898877@sarge>
NNTP-Posting-Host: coho.halcyon.com