Ryan's District
August 29, 2008, 08:26:13 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length

There are currently users in chat
News: Ryan's District Lottery: Claim your ticket or check
Jackpot details  
 
   Home   Help Search Chat Calendar Chess Shop Login Register  
Digg This!
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: C++ tips - Callbacks and multiple inheritance, part II  (Read 2994 times)
0 Members and 1 Guest are viewing this topic.
ben2ong2
Quality Poster
Paid
Hero Member
*****

Reputation: 17
Offline Offline

Gender: Male
Posts: 2374
9976.80 RD$

View Inventory
Send Money to ben2ong2

View Profile Awards
« on: October 07, 2006, 03:01:57 AM »

This example is based upon "Subobject Members", Stephen Dewhurst,
C++ Report, V5 N3. This is part 2 of a multipart example.

In this example, assume that the engine-button example of the previous
tip are extended two include two buttons. One will be for starting the
engine, one for stopping. Using the design technique of the previous
example, one would have:

.................................................................

class StartButtonCallback : public ButtonCallback {
  public:
    void callback () { start (); }
    virtual void start () = 0;
};

.................................................................

class StopButtonCallback : public ButtonCallback {
  public:
    void callback () { stop (); }
    virtual void stop () = 0;
};

.................................................................

class Engine : public StartButtonCallback,
          public StopButtonCallback {
    // ...
  public:
    void start ();
    void stop  ();
};

.................................................................

The first drawback with this approach is the global namespace
pollution introduced by the two callback classes. In addition,
these classes are unlikely to be reused except with engines.
Logged

You are not allowed to view links.
Register or Login
Free Paid Survey & Home Business Resources.

You are not allowed to view links.
Register or Login
Free Article Directory | Quality Content
Ryan's District
   

 Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Archive - WAP2 - WAP - imode
Sponsors: TOP SEO Directory - Online Job Maker - List of Advertisers - BIG VENUE

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.202 seconds with 28 queries.

Google visited last this page Yesterday at 08:09:30 AM