www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/22/17:45:30

From: "Al Morgan" <muaddib AT proaxis DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Help With Function Pointer Stuff
Date: Sat, 22 May 1999 13:41:07 -0700
Organization: Posted via RemarQ, http://www.remarQ.com - Discussions start here!
Lines: 29
Message-ID: <7i753f$j2e$1@remarQ.com>
NNTP-Posting-Host: 198.106.198.20
X-Trace: 927405999 XN.PZC.IPC614C66AC usenet58.supernews.com
X-Complaints-To: newsabuse AT remarQ DOT com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have a program that looks something like this:

class monster
    {
    int hitpoints;
    void *(ai)();
    };

void monster_ai_attack()
    {
    // kill the player
    if(monster_is_hit())
        --hitpoints;
    }

void main()
    {
    monster gremlin;
    gremlin.ai = monster_ai_attack;
    }

The problem is that the ai cannot access members of the class I assigned it
too.  (hitpoints).
Any suggestions?

Also, using C++, is there a reason to use a makefile, instead of a buch of
headers leading to one .CPP file?


- Raw text -


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