Home > Back-end >  Why usually only one meaning for variable, not to give more than one meaning
Why usually only one meaning for variable, not to give more than one meaning

Time:09-21

Why usually only one meaning for variable, not to give more than one meaning

CodePudding user response:

You can refer to a book
The write clean code

And variable name best since comments even effect, can search results

CodePudding user response:

Because habits 1 to 1

CodePudding user response:

Convenient maintenance and modification

CodePudding user response:

Because you learn less,
A variable can represent multiple meaning, of course,

For example
# define vegetable 1
# define meat 2
# define fish 4
8 # define milk

Int threes like to eat=vegetable | milk;
Int li si=meat | fish;

You see, with a variable says he likes to eat a variety of things

For example
The union MyData
{
The int value.
Struct Bytes
{
Char b1.
Char b2.
Char b3.
Char b4.
}
};

A variable can be split into four, can also be combined into one, more convenient,

For example
Sort (void * dat, size_t elesize, size_t n (int *) (void *, void *) CMP)
Here with a lot of void *, all kinds of data can be used to sort
  • Related