delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/17/19:17:10

Newsgroups: comp.os.msdos.djgpp
From: tob AT world DOT std DOT com
Subject: Re: An OOP question - pointer to member function
Message-ID: <ErKyCI.5q1@world.std.com>
Sender: tob AT world DOT std DOT com (Tom Breton)
Reply-To: tob AT world DOT std DOT com
Organization: BREnterprises
References: <3536C543 DOT 70D1EF9A AT ms1 DOT accmail DOT com DOT tw>
Date: Fri, 17 Apr 1998 22:55:30 GMT
Lines: 37
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

VAMPYR <vampyr AT ms1 DOT accmail DOT com DOT tw> writes:
> ==================================================
> class BASE
> {
>   public:
>     void (BASE::*member_func_ptr)(void);
> };
>
> class HERO : public BASE
> {
>   public:
>     void action(void);
> };
>
> void main()
> {
>   class HERO Vampyr;
>
>   Vampyr.member_func_ptr = &Vampyr::action;
                              ^^^^^^^^

No. Use "::" with the class name, not the object name.

Also, HERO::action is of the wrong type to assign to member_func_ptr,
(void (HERO::*) (void)). Making "action" a virtual function in "BASE"
should do what you want.


> }
> ==============================================

        Tom

--
After 1 July 1998 Washington state law levies a $500 fine for sending
e-mail to this address which conceals its point of origin or has a
misleading subject line.  The sender must determine recipient location.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019