|
-
February 16th, 2009, 02:42 PM
#23
Re: Newbie'z first real program. Could use some CONSTRUCTIVE critizism to learn...
 Originally Posted by Russco
Whilst strictly speaking this is allowed.....
Code:
#define maxrand 40
#define maxrand2 50
It is never a good idea to use macro's to represent constants. The much more correct way would be....
Code:
const int maxrand = 40;
const int maxrand2 = 50;
Use the preprocessor as little as possible. There are some things you have to use it for, but for constants and inline functions it shouldn't be used.
What are you basing that on? The first line in MSDN's documentation for #define says "You can use the #define directive to give a meaningful name to a constant in your program", and they do it all over the place.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|