Thursday 15 May 2014

class - C++ member function using another member function -


I am facing a major problem that I am trying to solve in vain for 3 days. I have got a CDS class with the intensity_func member function and the big_gamma member function which is basically an integral part of the member Intensity_func function

  #include   

And here is the CDS.cpp with definition of intensity_func member function:

  #include & lt; Vector & gt; # Include & lt; Random & gt; # Include & lt; Semith & gt; #include "CDS.h" double cds :: intensity_funk (double t) {vector & lt; Double & gt; X = it-> M_intensity; Of vector & lt; Double & gt; Y = it- & gt; M_paytimes; If (t> = y.back ()) t   

I have implemented the function to implement another source file and use the index_beta function intensity_func member Simpson's law in the function). Here is the code:

  double simple_accommonation (double (* fct) (double), double a, double b) {// [a; Making an integral part of a (continuous) function on b] // Simpson's rule used to return (BA) * (FTP) + FCT (B) + 4 * FCT ((A + B) / 2)) / 6 ; }; Double integration (double (* fct) (double), double a, double b, double n) {// integral is calculated using simple_ination function double plus = 0; Double H = (B-A) / N; For (double x = a; x & lt; b; x = x + h) {sum + = simple_integration (fct, x, x + h); } Refund Amount; }; Int index_beta (vector & lefthinum; double> gt; x, double tau) is to increase the vector x in order and if tau is double (tote & lt; x.back ()) {vector and lefthinini; Double & gt; :: Iterator = x. Start (); Int n = 0; While (* this & lt; tau) {++; ++ n; // or n ++; } Return n; } And {return x.size (); }};   

Therefore, I have to define the big_gamma member function in my CDS.cpp :

  Double CDS :: Big_Gamma ( Double t) {return integration (it-> intensity, 0, t); };   

But obviously, this does not work and I get the following error message: The reference to the non static member function should be called . I again tried to convert the intensity member function to a fixed function but new problems came out: I can not use the this-> m_intensity and - & Gt; M_paytimes and as I get the following error message: Invalid use outside of a non-static member function .

double (* fct) (double) type "pointer-to- Function ", you need to declare it as an" indicator-to-member function ": double (cds :: * fct) (double) . In addition, you need the object on which you are called Pointer-to-Member:

  (someObject-> fct) (someDouble);    

No comments:

Post a Comment