Re: 2D Vector Inside function
Do you intend to initialize a class member 2D vector from an arbitrary member function or do you want a 2D vector as a function-local variable? For the former you can just use the proposed syntax for initializing it from the constructor. In this respect the constructor and any other (non-static) member function are equivalent (but note that there are some fundamental aspects where they are not equivalent). For the latter (which I consider to be more likely), unlike the initialization of non-static member variables, you can use the "assign while declaring" initialization syntax; creation of the inner vectors would then be as we already had it:
Code:
MyMemberFunction()
{
vector<vector<int> ^> ^vector2D = gcnew vector<vector<int> ^>(13);
for (int i = 0; i < vector2D->size(); ++i)
vector2D[i] = gcnew vector<int>(13);
// Do whatever you want...
}
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Bookmarks