Avatar of 0av067
0av067
Flag for United States of America

asked on 

Cannot push back a CLI vector of strings.

I created a CLI vector of vectors of string handles.  Next, I tried to push back a vector of strings into the outer vector but this resulted in an error.  Intellisense does not open when I add the "->" after the name of my vector, however, it lets me push back a string handle into the vector within the vector of strings.  
Finally, If I just push back handles to strings to the vector of strings without first pushing back a vector of strings into the outer vector it results in a runtime error.  Please let me know if I can clarify anything.
#include "stdafx.h"
#include <cliext/vector>
 
using namespace System;
 
int main(array<System::String ^> ^args)
{
	//Declare a vector of vectors of strings called myvector
cliext::vector<cliext::vector<String^>^> myvector = gcnew cliext::vector<cliext::vector<String^>>;
 
//Declare and initialize a string
String^ mystring;
mystring = L"test string";
 
//The line below is the one that I can't figure out what I'm doing wrong
//myvector->push_back(cliext::vector<String^>^);   //(uncomment for the error)
 
//Push back the test string into a vector of strings within the vector, myvector
myvector[0]->push_back(mystring);
myvector[1]->push_back(mystring);
 
//This program results in a runtime error
 
    return 0;
}

Open in new window

Visual C++.NET

Avatar of undefined
Last Comment
0av067

8/22/2022 - Mon