#include "Rtypes.h" #include "RArray.h" int main() { RArraymyArray(5); // create a double array with 5 elements // elements are initialized to 0.0 by default return 0; }
#include "Rtypes.h" #include "RArray.h" int main() { RArraymyArray; myArray.Resize(5); // resize the array to hold 5 elements for (int i = 0; i < myArray.GetSize(); i++) { myArray[i] = i; // add elements to the array using the subscript operator } return 0; }
#include "Rtypes.h" #include "RArray.h" #includeIn the first example, we create an RArray with 5 elements of type double. In the second example, we resize the RArray to hold 5 elements and then add elements using the subscript operator. In the third example, we create an RArray with 4 elements of type double, add values to it, and then access the third element using the subscript operator. In conclusion, RArray is a package library in C++ provided by ROOT. It provides resizable arrays that can be dynamically resized at runtime. It is used mostly in high energy physics experiments.int main() { RArray myArray(4); myArray[0] = 1.0; myArray[1] = 2.0; myArray[2] = 3.0; myArray[3] = 4.0; std::cout << myArray[2] << std::endl; // prints 3.0 return 0; }