array<bool^> ^ test = gcnew array<bool^>{ randombool1, randombool2 };
at best I can do this bool arr[2] = {randombool1, randombool2};
However that doesn't put variables into the array. It puts values of those variables. I need to be able to access the variables themselves.
-------------------------
Another question I have is how do you parse a variable.
Meaning lets say I have variables named. Variable1 Variable2 Variable3 Variable4
For a specific reason I need to look up the number lets say I want Variable3 if the loop item I'm looking at is 3 and then assing another variable the content of Variable3.
I haven't figured out a way to do this. I could do this with other languages very easily. But C++ seems difficult about this (for no reason at all).
How would I use pointers to do this? I'm very new I don't really understand pointers to be honest. I have used them but I don't really know enough about them. They seem a bit alien to me. I'm used to scripting where everything is just letters.
I figured there was enough similiarity to where people could help me with:
1) Making an array with Boolean variables
2) Parsing variables. So Variable1 Variable2 Variable3 finding that 1,2,3 and assigning or grabbing information from those variables.
I guess nobody knows. Haven't been able to google it either. Sad because much simpler languages can do this with absolute ease. Yet C++....... its a big mystery :(
I guess nobody knows. Haven't been able to google it either. Sad because much simpler languages can do this with absolute ease. Yet C++....... its a big mystery :(
You're using C++/CLI, not C++. Considering Microsoft made C++/CLI, it's no wonder it's a big mystery.
I've asked a few questions here before... with C++ in mind. And the answers have worked.
So it's not like it's a completely different thing. There are differences. But there is enough similarities to where I can ask questions here about it.
This does not set Bool1 to false. Heck it doesn't even compile. I tried &Bool1 that doesnt work either.
This half way works array<bool> bah = gcnew array<bool>
But all it does is grab the values from whatever I assign, it doesn't actually store the variables themslves. So for example if I assigned Bool1 and Bool2, it would only grab the true/false values from them but it wouldn't hold the variables themselves. So I have to go back and do this
1 2
Bool1 = bah[0];
Bool2 = bah[1];
Which is a workaround sure. But it's very ugly and god forbid I had a big array.
There has to be a better way of doing this. So far nobody knows :(
Neither do I LB. I just thought I'd follow the bool sidetrack for curiosity sake.
Unless the OP uses classes or structs with a name attribute then I doubt whether its possible to extract the variable name easily at runtime. It's obviously stored somewhere but where and in what form would be an interesting challenge. I suspect a futile one.
Since this is C++/CLI and the Bool is declared outside of the function........ It throws up this disgusting error...
error C2440: 'initializing' : cannot convert from 'cli::interior_ptr<Type>' to 'bool *const '
1> with
1> [
1> Type=bool
1> ]
1> Cannot convert a managed type to an unmanaged type
If I use a bool that is declared within the function it's not a problem. But obviously for this to work I need to access the Bool I declared globally...... *SIGH*.
THIS IS SO OVERCOMPLICATED!
But I do thank you for answering the original question.