I’d like to create variables “automatically” with #declare. So, I don’t want to type to new variable’s class definition many times (actually I’m declaring multidimensional vectors, not simple integers…)
I have this code:
#define inti(aa)(int (aa)=3)
...
inti(a);
But the compiler says:
“error: ‘a’ was not declared in this scope”
Is it possible to solve this problem in C++? Please help!
Use:That’s because
is illegal, even more what you have there.
Actually, scratch that. Don’t use a macro. Just declare your variables the good old-fashioned way.
+1 for the question for stating your actual problem. This is what a
typedefis for.