J
JKop
const unsigned short int AmountHumanAdultTeeth = 32;
inline unsigned short int AddFive(unsigned short int Numbr)
{
return Numbr + 5;
}
USE THESE!!
I've heard a stupid argument before that:
#define AmountHumanAdultTeeth 32
is better because it saves memory, ie. there's no variable declared which
takes up memory.
Enlightenment time:
Upon execution, the ENTIRE program is loaded into memory, all the code for
all of the functions, all of the numbers and strings littered throughout the
code, eg.:
cout << "Hello";
are all loaded into memory. Thus, somewhere in memory you will have "Hello".
Thus, concordantly and therefore, you most certainly _are_ taking up memory
by using a macro instead of a const global variable. Furthermore, you may
even use MORE memory with a macro; For example, if you have the number "5"
littered throughout your program, you're not necessarily guaranteed that all
of the "5"'s will be taken from the same place in memory! There may be a
unique "5" in memory for every single seperate time you use it. Const global
variables are superior in EVERY WAY, BAR NONE.
As for macro functions: Similarly, there is absolutley NO JUSTIFICATION for
their use. Inline functions are superior in every way, BAR NONE!
inline unsigned short int AddFive(unsigned short int Numbr)
{
return Numbr + 5;
}
USE THESE!!
I've heard a stupid argument before that:
#define AmountHumanAdultTeeth 32
is better because it saves memory, ie. there's no variable declared which
takes up memory.
Enlightenment time:
Upon execution, the ENTIRE program is loaded into memory, all the code for
all of the functions, all of the numbers and strings littered throughout the
code, eg.:
cout << "Hello";
are all loaded into memory. Thus, somewhere in memory you will have "Hello".
Thus, concordantly and therefore, you most certainly _are_ taking up memory
by using a macro instead of a const global variable. Furthermore, you may
even use MORE memory with a macro; For example, if you have the number "5"
littered throughout your program, you're not necessarily guaranteed that all
of the "5"'s will be taken from the same place in memory! There may be a
unique "5" in memory for every single seperate time you use it. Const global
variables are superior in EVERY WAY, BAR NONE.
As for macro functions: Similarly, there is absolutley NO JUSTIFICATION for
their use. Inline functions are superior in every way, BAR NONE!