Undeclared identifier and expected unqualified-id

I got this error:

//=======
In file included from input_line_100:1:
/home/jaybee/JaybeeCodes/Example.C:23:30: error: use of undeclared identifier
      'amp'
   ROOT::Math::Functor1D wf(&f);
                             ^
/home/jaybee/JaybeeCodes/Example.C:56:28: error: use of undeclared identifier
      'amp'
   ROOT::Math::Functor wf(&f2,2);
                           ^
/home/jaybee/JaybeeCodes/Example.C:93:1: error: expected unqualified-id
</cmath>
^
//=======

when I ran this program:

//=======
#include "Math/Integrator.h"
#include "Math/IntegratorMultiDim.h"
#include "Math/AllIntegrationTypes.h"
#include "Math/Functor.h"
#include "Math/GaussIntegrator.h"
 
#include <cmath>
 
const double ERRORLIMIT = 1E-3;
 
double f(double x) { 
   return x; 
} 
double f2(const double * x) { 
   return x[0] + x[1]; 
} 
 
int testIntegration1D() { 
 
   const double RESULT = 0.5;
   int status = 0;
 
   ROOT::Math::Functor1D wf(&amp;f);
   ROOT::Math::Integrator ig(ROOT::Math::IntegrationOneDim::kADAPTIVESINGULAR); 
   ig.SetFunction(wf);
   double val = ig.Integral(0,1);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   ROOT::Math::Integrator ig2(ROOT::Math::IntegrationOneDim::kNONADAPTIVE); 
   ig2.SetFunction(wf);
   val = ig2.Integral(0,1);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   ROOT::Math::Integrator ig3(wf, ROOT::Math::IntegrationOneDim::kADAPTIVE); 
   val = ig3.Integral(0,1);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   //ROOT::Math::GaussIntegrator ig4;
   ROOT::Math::Integrator ig4(ROOT::Math::IntegrationOneDim::kGAUSS); 
   ig4.SetFunction(wf);
   val = ig4.Integral(0,1);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   return status;
}
 
int testIntegrationMultiDim() { 
 
   const double RESULT = 1.0;
   int status = 0;
 
   ROOT::Math::Functor wf(&amp;f2,2);
   double a[2] = {0,0};
   double b[2] = {1,1};
 
   ROOT::Math::IntegratorMultiDim ig(ROOT::Math::IntegrationMultiDim::kADAPTIVE); 
   ig.SetFunction(wf);
   double val = ig.Integral(a,b);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   ROOT::Math::IntegratorMultiDim ig2(ROOT::Math::IntegrationMultiDim::kVEGAS); 
   ig2.SetFunction(wf);
   val = ig2.Integral(a,b);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   ROOT::Math::IntegratorMultiDim ig3(wf,ROOT::Math::IntegrationMultiDim::kPLAIN); 
   val = ig3.Integral(a,b);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   ROOT::Math::IntegratorMultiDim ig4(wf,ROOT::Math::IntegrationMultiDim::kMISER); 
   val = ig4.Integral(a,b);
   std::cout << "integral result is " << val << std::endl;
   status += std::fabs(val-RESULT) > ERRORLIMIT;
 
   return status;
}
 
int  main() { 
   int status = 0;
 
   status += testIntegration1D();
   status += testIntegrationMultiDim();
 
   return status;
}
</cmath>
//=======

want some help :slight_smile: thanks…
i am new with ROOT programming, though…

List of XML and HTML character entity references

Where did you copy the code from? &amp; is the HTML escape for the ampersand. Just replace all &amp; in your code with &.

I got it from here: https://root.cern.ch/function-integration
I am slowly exploring ROOT :slight_smile:

Thanks,
Jaybee

this is now the error:

//=======
In file included from input_line_110:1:
/home/jaybee/JaybeeCodes/Example.C:26:30: error: expected expression
ROOT::Math::Functor1D wf(&;f);
^
/home/jaybee/JaybeeCodes/Example.C:59:28: error: expected expression
ROOT::Math::Functor wf(&;f2,2);
^
/home/jaybee/JaybeeCodes/Example.C:97:1: error: expected unqualified-id

^
//=======

&amp;