I have a class defined as:
class Obj {
public:
int width, height;
Obj(int w, int h);
}
and I need it to contain a static array like so:
int presc[width][height];
however, I cannot define within the class, so it it possible to create a pointer to a 2D array (and, out of curiosity, 3, 4, and 5D arrays), have that as a member ...
One can define a static array at compile time as follows:
const std::size_t size = 5;
unsigned int list[size] = { 1, 2, 3, 4, 5 };
Question 1 - Is it possible by using various kinds of metaprogramming techniques to assign these values "programmatically" at compile time?
Question 2 - Assuming all the values in the array are to be ...
How can i define a STATIC array of numbers accessible to all methods in my class???
...
We all know the basic rules for static array:
int size = 20;
char myArray[size];
is not legal.
And.
const int size = 20;
char myArray[size];
is OK.
But, what about this.
int f(const int size)
{
char myArr[size];
}
void main()
{
f(2);
f(1024);
}
MSVC says it is an error, gcc seems to compile and execute it fine.
Obvi...