Answer the question
In order to leave comments, you need to log in
How to make a global dynamic array in C++?
I need to create a global dynamic array from wstring type vectors;
I try like this: vector<wstring> **oldnwords, **oldnnwords;
then inside the main function I do this: oldnwords = new vector<wstring>[(i+rows)];
then I put my vectors into it.
Further, inside another function, I try to access the array - it contains 0 elements.
how to make it work?
PS: I understand that doing this is not right, not kosher and generally evil. but I need to do it this way, and not otherwise.
I will be grateful for a constructive answer.
Answer the question
In order to leave comments, you need to log in
Global objects are evil. It's better to pass a pointer to an array as a function argument and everything will be fine. And stop doing functional stuff, use the power of OOP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question