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:
#define inti(aa) int aa=3
That's because
(int aa=3);
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.
actually I'm declaring multidimensional vectors
+1 for the question for stating your actual problem. This is what a typedef is for.
typedef std::vector<std::vector<int> > MDVector;
MDVector multiDimensionalVector;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With