// Initial declarations
    
    #include "hush.h"
    
    double newton(double arg);    // declare the function
    
    char* ftoa( double f);        // to convert float to char*
    
    // The generator (handler) class gives access to the widgets
    
    class generator : public handler {   
    public:
      
      generator() {                        // access to Tcl widgets
      	s = (scale*) new widget(".s");
      	m = (message*) new widget(".m");
      }
      
      ~generator() {
      	s->destroy(); m->destroy(); // to destroy widgets
      	delete s; delete m;       // to reclaim resources
      }
      
      int operator()() {             // the generator action
    	float f = s->get();
    	m->text( ftoa( newton(f) ) );     // display value
    	return OK;
    }
    
    private:
      scale* s;
      message* m;
    };
    
    // The application class takes care of installing the interface
    
    class application : public session { 
    public:
      application(int argc, char* argv[])
  			     : session(argc,argv,"newton") {}
      
      void main( ) {                    // tk is an instance variable
          
          tk->source("interface.tcl");  // read interface script
          handler* g = new generator(); 
      
          tk->bind("generate",g);     // bind Tcl command
      }
    };
    
    // Finally, the function main is defined
    
    void main (int  argc, char  **argv) { 
        session* s = new application(argc,argv);
        s->run();
    }
    
  

slide: The C++ program