cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/11/03:35:49

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: calling a pointer to a function
Date: Thu, 11 Nov 1999 02:45:57 -0500
References: <382917AA DOT 256A0891 AT home DOT com>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 11 Nov 1999 07:45:43 GMT
X-ELN-Insert-Date: Wed Nov 10 23:55:03 1999
Organization: Nocturnal Aviation
Lines: 63
Mime-Version: 1.0
NNTP-Posting-Host: dialup-209.244.183.203.newyork2.level3.net
Message-ID: <382A7435.C419239B@earthlink.net>
X-Mailer: Mozilla 4.7 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


Robin Johnson wrote:
> 
> Hi,
> 
> I used to do something in Pascal, and i was wondering what the C++
> conversion of it was:
> {begin pascal code}
> Type tProc = Procedure(Num : integer);
> 
> Procedure Do1(Num : integer);
> begin
> end;
> 
> Procedure Do2(Num : integer);
> begin
> end;
> 
> Procedure CallOne(aProc : tProc)
> var x : integer;
> begin
>  x := 1;
>  aProc(1);
> end;
> {end pascal code}
> how to do this in C++? namely DJGPP, with DPMI.
> Can anybody help?

typedef void (*tproc)(int);
void Do1(int Num)
{
}

void Do2(int Num)
{
}


void CallOne(tproc aProc)
{
  int x;
  x = 1;
  aProc(1);
}


int main(int argc, char *argv[])
{
    CallOne(Do1);
    CallOne(Do2);
    return 0;
}




-- 
Martin Ambuhl	mambuhl AT earthlink DOT net

__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

- Raw text -


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