within a windows forms class (form1) I declared a cliext vector of vectors of strings with

cliext::vector<cliext::vector<String^>^> myvector;

. Then, within a function in that same class I tried to push back a vector of strings in myvector but it resulted in an error. I attempted to push back the vector of vectors by using


. I can't figure out what I'm doing wrong here. I also tried to initialize myvector using

cliext::vector<cliext::vector<String^>^> myvector = gcnew cliext::vector<cliext::vector<String^>>;

within the function in the form1 class but this did not help. Debugging tells me that the vector type does not have an overloaded "->" operator. I know what an overloaded operator is but I don't know what to make of this.
If I completely missed the protocol of how to enter code in this forum please let me know, this is my first post:)

Member Avatar for jencas

I think String^ is like a C++ reference and thus cannot be stored in a STL container. But don't blame me if this is not right, cause I'm not familiar with mixing native C++ and C++/CLR.

I thought I was using a CLR vector by including the header <cliext/vector> and refering to the vector as cliext::vector. The weird thing is that Intellisense lets me push back a string into one of the vectors withing the vector of strings ie



Why are you using C++/CLI and not something like C#?

Why are you using C++/CLI and not something like C#?

I don't know how to use C# yet. I'm trying to use Windows Forms in Visual Studio Express 2008 and within the Form1 class that it generates for the GUI I'm just trying to use this vector of vectors of string handles. I can't figure out why it won't let me push back a vector of strings into the first vector but it will let me push back a string into a vector of strings within the the first vector.

Well, you would have an easier time using C#.

Can anyone help me figure this one out?

C# is easy to learn, and unless you have a very specific, articulable reason to be using C++/CLI, you would be better off going with C#.

Edit: Also, don't expect an answer here; your question is offtopic in a C++ forum.

I just wrote a program to search an inventory in native C++ and needed a GUI to allow user interaction so I turned to windows forms, hence the managed C++. Which forum should I ask this question? The VB.net forum perhaps?

Maybe this is a stupid question, but why you writing myvector->push_back(...) instead of myvector.push_back(...) ? myvector is a cliext::vector<T>, not a cliext::vector<T>^.

As it turns out, thats half the problem. The other half is that its not possible to pushback a vector of strings into a vector before the vector of strings has been initialized.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.