H
Huibuh
The following code is a function called from the main. Sence is to
initialize a vector of the dimension of "a". "b" is the according value (all
the same in a vector).
The problem is that the initialization is done the right way (controled by
the output) but the returned vector is empty - meaning the pointer is
showing zero.
vector<int>* initialize (int a, vector<int>* vec, int b)
{
vector<int> ve;
vec=&ve;
ve.reserve(a);
for (int i=0; i<=a-1; i++)
ve=b;
for (i=0; i<=a-1; i++)
cout << i << ". value : "
<< ve << endl;
return vec;
ve.clear();
}
What is wrong???
I have tried it before without using a pointer - same result!
initialize a vector of the dimension of "a". "b" is the according value (all
the same in a vector).
The problem is that the initialization is done the right way (controled by
the output) but the returned vector is empty - meaning the pointer is
showing zero.
vector<int>* initialize (int a, vector<int>* vec, int b)
{
vector<int> ve;
vec=&ve;
ve.reserve(a);
for (int i=0; i<=a-1; i++)
ve=b;
for (i=0; i<=a-1; i++)
cout << i << ". value : "
<< ve << endl;
return vec;
ve.clear();
}
What is wrong???
I have tried it before without using a pointer - same result!