www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/03/17:38:40

From: jpdelprat AT teaser DOT fr (Jean-Pierre Delprat)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: JPTUI Question
Date: Tue, 03 Dec 1996 21:43:34 GMT
Organization: Guest of France-Teaser
Lines: 46
Message-ID: <582aa4$i8g@news.teaser.fr>
References: <32A420CE DOT 6006 AT cornell DOT edu>
NNTP-Posting-Host: ppp2816-ft.teaser.fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"A. Sinan Unur" <asu1 AT cornell DOT edu> wrote:

>i recently downloaded jptui and i am trying to use to build the user
>interface of one of my programs. i also thought it would be a good way
>to finally venture into c++. (i have some knowledge of c++, mainly
>through doing examples in books, but so far i have been to lazy to do
>anything of my own.) anyway, the following question probably reflects my
>ignorance more than anything else.

>in the program, i would like to keep track of a group of "button-like"
>entities and, when needed, provide a visual version. a cut down version
>of my "solution" is below. Essentially, i want this class to provide a
>common callback for all the buttons in the group.

>When i try to compile this, with , -Wall, -02 and -m486, i get the
>following message:

>layout.cc: In method `void ButtonArray::SetCallbacks()':
>layout.cc:63: bad argument 1 for function `void
>TPushButton::m_set_pressed_callback(void (*)(class TObject *, char *),
>char *)' 
>(type was void (ButtonArray::)(class TObject *, char *))


I've tried to compile your program with the Borland C++ and it works
fine, but I've already had similar problems.

In my opinion, the problem is that you can only pass static functions
(not true methods) as an argument for the callbacks. The solution is
to declare your method as a static method :

class blahblah
{
  static   void Pressed(PObject sender, char *);

}

Of course, you may have to change your code a little since a static
method is common to all the instances of this class. So this method
doesn't know which instance it depends on (use a pointer to the
current instance)
Jeepy (Jean-Pierre Delprat)
jpdelprat AT teaser DOT fr
www.teaser.fr/~jpdelprat (JPTUI home page)


- Raw text -


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