Last change
on this file since 3739 was 3409, checked in by cmv, 18 years ago |
operator(double) de ClassFunc et GenericFunc n'est plus const , cmv 25/11/2007
|
File size:
774 bytes
|
Rev | Line | |
---|
[2283] | 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 |
|
---|
[3098] | 12 | //! Abstract interface definition for functions (double f(double)) viewed as classes
|
---|
[2283] | 13 | class ClassFunc {
|
---|
| 14 | public:
|
---|
[3108] | 15 | virtual ~ClassFunc(void) { }
|
---|
[3409] | 16 | virtual double operator()(double x) =0;
|
---|
[2283] | 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){}
|
---|
[3409] | 25 | virtual double operator()(double x) { return f(x);}
|
---|
[2283] | 26 | };
|
---|
| 27 |
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.