• Create Account

Banner advertising on our site currently available from just \$5!

### #Actualultramailman

Posted 11 February 2013 - 05:28 PM

'array' is a keyword in C++ IIRC, so it's a good habit to not use it as a variable name. Rather than using #define to define constants it's better to just make constants:

const size_t SIZE = 10;
This gives you type control and avoids macro expansion problems like the one you encountered.

Using #define is almost the same as using your a text editor's 'find-and-replace' function. There are some cases where it's useful, but usually it causes more problems than it solves.

I am pretty sure "array" is not a keyword in c. There is the std::array type, but that's only in c++.

Also, nice analogy there with the "find and replace", I've never thought about it like that.

### #1ultramailman

Posted 11 February 2013 - 03:15 PM

'array' is a keyword in C++ IIRC, so it's a good habit to not use it as a variable name. Rather than using #define to define constants it's better to just make constants:

const size_t SIZE = 10;
This gives you type control and avoids macro expansion problems like the one you encountered.

Using #define is almost the same as using your a text editor's 'find-and-replace' function. There are some cases where it's useful, but usually it causes more problems than it solves.

Pretty sure "array" is not a keyword, although there is the std::array type.

Also, nice analogy there with the "find and replace", I've never thought about it like that.

PARTNERS