How do I initilize a "vector <wstring> vtws" variable?

Hi, I'm getting a "Uninitilize memory error" in a tool called Purify.  It's pointing to my varilable declared as below. How do I initilize such variable (a vector for storing wstring)?  Thank kyou.
vector <wstring> vtws
Who is Participating?
jkrConnect With a Mentor Commented:
There is no real need to initialize a vector, since it is a container that is filled later. If you want to, you could use

vector <wstring> vtws;

BTW, Is that the complete snippet? If so, Purify is wrong here.
lapuccaAuthor Commented:
I think that error went away.  Let me verify and get back to you.  Thank you.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
Below is the correct way to initialize it; however, since vector's have a default constructor it isn't necessary and as such Purify is being less than clever about this (I have had nothing by poor experiences using Purify!).

std::vector<std::wstring> vtws = std::vector<std::wstring>();

Open in new window

>>>> (I have had nothing by poor experiences using Purify!)
I didn't use Rational Purify myself, but all meanings I heard from were similar to the above.

>>>> vector <wstring> vtws;
Nevertheless, Purify may have detected some kind of data corruption, or show some wrong variables due to 'Precompiled Header' mix-up. If the error vanished without being reproducable, I would assume an error like that rather than a fundemental Purify problem.

Regards, Alex
lapuccaAuthor Commented:
Can't use the following in the declaration in the .h file.  Got 4 errors duing compilation.
std::vector<std::wstring> vtws = std::vector<std::wstring>();
evilrixSenior Software Engineer (Avast)Commented:
Well yes, that would make sense :) You shouldn't defining things in your header file, this is what .cpp files are for. .hpp files are for declarations.
All Courses

From novice to tech pro — start learning today.