D
D
DiIce2016-01-19 10:40:53
C++ / C#
DiIce, 2016-01-19 10:40:53

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

2 answer(s)
M
maaGames, 2016-01-19
@DiIce

vector< vector< wstring > > oldnwords ;

A
Anatoly Medvedev, 2016-01-19
@balamyt92

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 question

Ask a Question

731 491 924 answers to any question