Last change
on this file since 3389 was 3108, checked in by cmv, 19 years ago |
intro d un destructeur virtuel cmv 20/11/06
|
File size:
786 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) { }
|
---|
[3098] | 16 | virtual double operator()(double x) const =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){}
|
---|
[3098] | 25 | virtual double operator()(double x) const { return f(x);}
|
---|
[2283] | 26 | };
|
---|
| 27 |
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.