[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [COMP/HELP]Generalised event handler



Cha`o ba'c Huy,
  Kho^ng hie^?u ro~ y' ba'c la('m, ba'c ho?i la` du`ng Windows hay du`ng C++ 
cho ca^u ho?i ddo'?
1/ Du`ng Windows - co' ca'ch map su+. kie^.n thay ddo^?i vu`ng bo^. nho+' 
vo+'i mo^.t function. But I have check for sure.
2/ Du`ng debug: co' the^? dda(.t break point ma` se~ chu+o+ng tri`nh bi. 
du+`ng la.i khi 1 bie^'n na`o ddo' thay ddo^?i, ba^'t ke^? thay ddo^?i 
kie^?u gi`.

3/ Du`ng C++:

Wrap ca'i bie^'n ddo' va`o mo^.t class, co function ddu+o+.c go.i khi member 
thay ddo^?i. Vi' du. nhanh:

class Status
{
  bool symtomp;
  void TakeImmodiumTablet ();
public:
  bool operator = (bool s)
   {
     symptom = s;
     if (symptom)
       TakeImmodiumTablet ();
     return symptom;
   }
};

Nhu+ va^.y khi ba'c vie^'t
{
Status LooseTool, LooseTool1;
....
LooseTool = true;
...
LooseTool = LooseTool1 = false
...
}

  Thi` TakeImmodiumTablet se~ tu`y co+ ddu+o+.c go.i.
Cheers,
Tuan Anh.

From: "HUY DUONG" <huy.duong@ctsu.ox.ac.uk>
>Reply-To: vnsa@list-server.net
>To: vnsa-digest@List-Server.net
>Subject: [COMP/HELP]Generalised event handler
>
>In Windows programming we have event handlers that get
>called when an event such as a mouse click occurs.
>
>I've been thinking that it would be nice to be able to include
>in a function's definition when that function would be called.
>
>Eg:
>
>We have the function TakeImmodiumTablet. It would be
>nice to specify in the function definition that it would
>get called whenever LooseStool is true, no matter how
>that occurs. That would be nicer than having to specify in the
>program
>
>EatSourFruit, if LooseStool then TakeImmodiumTablet,
>...
>DringSimmingPoolWater, if LooseStool then TakeImmodiumTablet,
>...
>EatUnwashedVegetable, if LooseStool then TakeImmodiomTablet.
>
>Can I do that in C++?
>


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com