use data stored in another function ionvolving header

My Case is like this

---------------------
//abc.h

Public:
void write();
void read();

Private:
int number_of_item;

---------------------
//abc.cpp

void write()
{
number_of_item = 3;
int array[number_of_item];

array[0] = 0;
array[1] = 1;
array[2] = 2;
}

void read()
{
int array[number_of_item];
cout << array[0] << array[1] << array[2] << endl;
}

----------------------------------------

After calling write and then read,
the output will be a mess instead of 123.
How can I modify toget the result of 123?
Thanks for reading, and I am in a hurry,
so I didn't pay attention to the syntax of the brief example above,
hope that you can understand my code.
Don't C-style arrays require const-expressions in their declaration? Why don't you use a std::vector?
Well actually I'm doing an assignment.
It requires me to implement a read function to store an image in gray scale in the format of 2D array, and then use it for other functions.
I guess I will use brut force method by intializing the array in private section using a very big number.
Topic archived. No new replies allowed.