#include#include "IntArray.h" int main() { IntArray arr(5); int values[] = {1, 2, 3, 4, 5}; arr.setValues(5, values); for (int i = 0; i < arr.size; i++) { std::cout << arr[i] << " "; } return 0; }
#includeIn this example, we create an IntArray with a size of 3 and try to set its values using an array of 5 integers. This will result in undefined behavior since we are trying to write to memory outside the bounds of the array. The library/package that contains the IntArray class is not specified in the description.#include "IntArray.h" int main() { IntArray arr(3); int values[] = {1, 2, 3, 4, 5}; arr.setValues(3, values); for (int i = 0; i < arr.size; i++) { std::cout << arr[i] << " "; } return 0; }