I am new to C/C++ and I had a question about dynamically allocating arrays. Can you not make a global dynamically allocated array? What if I wanted arr to be used by multiple functions? Would I have to pass arr to every function? Basically I guess I am still confused on the concept of dynamically allocated arrays and how I could create an array that can be used by a few functions.
The following produces : error: ‘arr’ does not name a type, but I am not sure exactly why.
#include <iostream>
using namespace std;
int * arr = NULL;
arr = new int [10];
int main() {
arr[0] = 1;
return 0;
}
new:)