1
Is it possible to concatenate the name of a variable into C++? Something like this:
using namespace std;
int main()
{
int casa = 10;
string a = "ca";
string b = "sa";
cout << a+b << endl;
/*** console imprime int casa ***/
/*** result console: 10 ***/
return 0;
}
No. They’re different variables. Maybe you get a similar effect using pointers, but not exactly this way.
– anonimo
Thanks considering for a new perspective, look at this: for (int i = 1; int < 100, int++) Cout << int(i) << Endl;
– mrsoliver
What you want doesn’t even make sense, say what you want, there’s another solution to this without doing what you’re asking.
– Maniero
I have 300 variables type int. And I want to print a list of it, without having to type Cout << my_int1... Cout << my_int2 300 times....
– mrsoliver
Take a look at the array, it might help.
– anonimo
@mrsoliver Has the answer solved your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero