Avatar of 0av067
0av067Flag 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
Subrat (C++ windows/Linux)

I amn't well on this type of syntax(string^).
I hope you migh t hav to use
String^ mystring;
>>>>>mystring = L"test string";
               mystring = new String(L"xyz")
ASKER
0av067

I'm not sure I understand your response.  I'm using a System string handle.  

Also, the question I'm focused on is why I cannot push back a vector that contains strings into a vector that contains vectors that contain strings (try saying that three times fast).
ASKER CERTIFIED SOLUTION
0av067

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck