Hello,
         I tried a small program which gives me a callback function.
----------------------------------------------------------------------------
class callback{
public:
  int (*fp)();
  friend int display();
};

int display()
{
 cout<<"I am calling callback function....";
 return 1;
}
int main()
{
 callback instance;
 instance.fp=display;
 int nCheck=(*instance.fp)();
 if(nCheck==1)
 {
  cout<<"i m done with callback"<<endl;
 }
 getchar();
  return 0;
}



On Wed, Jan 27, 2010 at 5:46 PM, Jimmy Johnson <[email protected]> wrote:

>
>
> I am not up to c-proficiency yet to understand what you mean. Do you mean
> put these features/pattern into the class and make them static?
>
>
> displayable* myWin := NULL
> void myWinReshapeWrapper (int h, int w) {
> myWin->onReshape;
> };
>
> In this pattern the reference to myWin represents the state on which to
> call onReshape. I don't know how I could set the state in that case. A
> callback would have to be executed on, say a mouse click, to set the "state"
> to the window referenced by myWind, but in order to execute the callback on
> that window I need the stat to already be that window. Chick-and-egg.
>
> What is "delegate to" a singleton? I need to instantiate more than one
> object of type displayable so making it a singleton will not work. Can you
> explain "delegate to a singleton"?
>
> thanks,
>
>
> --- In [email protected] <c-prog%40yahoogroups.com>, John Gaughan
> <j...@...> wrote:
> >
> > On 1/26/2010 12:53 PM, Jimmy Johnson wrote:
> > > To boil it down, I want to create new functions to be used as callbacks
> which will call a c++ method on the correct object.
> > >
> >
> > How about using static members of a class that either deal with static
> > state or delegate to a singleton?
> >
> > --
> > John Gaughan
> > http://www.jtgprogramming.org/
> >
>
>  
>



-- 
----------------------------
Regards
Shantibhushan Sale
Mumbai
+91 9769396331


[Non-text portions of this message have been removed]

Reply via email to