| Last change
 on this file since 3343 was             3108, checked in by cmv, 19 years ago | 
        
          | 
intro d un destructeur virtuel  cmv 20/11/06
 | 
        
          | File size:
            786 bytes | 
      
      
| Line |  | 
|---|
| 1 | //////////////////////////////////////////////////////////////// | 
|---|
| 2 | //this class provides an alernative to functions which can be viewed as classes | 
|---|
| 3 | //                          S.Plaszczynski 29/11/02 | 
|---|
| 4 | ////////////////////////////////////////////////////////////////////// | 
|---|
| 5 |  | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef CLASSFUNC_H | 
|---|
| 8 | #define CLASSFUNC_H | 
|---|
| 9 |  | 
|---|
| 10 | namespace SOPHYA { | 
|---|
| 11 |  | 
|---|
| 12 | //! Abstract interface definition for functions (double f(double)) viewed as classes | 
|---|
| 13 | class ClassFunc { | 
|---|
| 14 | public: | 
|---|
| 15 | virtual ~ClassFunc(void) { } | 
|---|
| 16 | virtual double operator()(double x) const =0; | 
|---|
| 17 | }; | 
|---|
| 18 |  | 
|---|
| 19 | //ClassFunc constructed from a a function:simple forward to function | 
|---|
| 20 | class Function : public ClassFunc { | 
|---|
| 21 | private: | 
|---|
| 22 | double (*f)(double); | 
|---|
| 23 | public: | 
|---|
| 24 | Function(double (*g)(double)):f(g){} | 
|---|
| 25 | virtual  double operator()(double x) const { return f(x);} | 
|---|
| 26 | }; | 
|---|
| 27 |  | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
| 30 | #endif | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.