Let's look at a few examples
(1) struct{int x; int y;} Test1;
Well, define the structure test1,
test1.x and test1.y can be used in the statement.
(2) struct test {int x; int y;} Test1;
Well, define the structure test1,
test1.x and test1.y can be used in the statement. Compared
with 1, the province wrote Test
(3)
typedef struct TEST
{int x; int y;
} TEXT1,TEXT2;
Only said that the structure of the (
In php, both define () and const () can define constants. So what is the difference between define () and const? many programmers do not understand this, I will introduce you
In php, both define () and const () can define constants. So what is the difference between
: This article mainly introduces the difference between const and define in php (supplement). If you are interested in PHP tutorials, refer to it. A constant is the identifier (name) of a simple value ). As its name implies, this value cannot be changed during script execution (except for so-called magic constants, they are actually not constants ). Constants are case sensitive by default. Constant identifiers are always capitalized.
You can use the
In # define, the standard defines only # and # #两种操作. #用来把参数转换成字符串, # #则用来连接两个前后两个参数, turn them into a string.#define CONN (x, y) x# #y//connection X, Y#define TOCHAR (x) #@x//Plus Single quote#define TOSTRING (x) #x//plus double quotation marksRecently read the COM related information, see CCmdTarget Implement COM int
#define是C语言中提供的宏定义命令, the main purpose is to provide programmers with a certain degree of convenience in programming, and to a certain extent to improve the efficiency of the program, but students often do not understand the nature of the command, always here to create some confusion, the programming misuse of the command, So that the operation of the program is inconsistent with the intended purpose, or read the program written by others, the results
Macro definition in C # define usage,
# Define is a macro definition Command provided in C language. Its main purpose is to provide programmers with some convenience in programming and improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command, and there is always some confusion here. The command is misused dur
# Define is a macro definition Command provided in C language. Its main purpose is to provide programmers with some convenience in programming and improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command, and there is always some confusion here. The command is misused during programming, so that the program runs differently from the expected purpose, or
Label: style blog Io ar use for strong SP Div 1) # define is a pre-processing command. It is a simple replacement during compilation and pre-processing, and does not check the correctness. It does not mean that it is correct or not, possible errors are detected and reported only when the expanded source program is compiled. For example:# Define PI 3.1415926In the program: Area = pI * r will be replaced with
1.1. # define variant, that is, # ifndef, can prevent repeated references to header files# Ifdef and # define combinations are generally used in header files to prevent repeated references of multiple files to the same header file.In actual use, even if your header file is not referenced by multiple files, it is best to add it to increase program readability, portability, robustness, and so on.Its usage is
Today, we have compiled some # define usage to share with you!1. Simple define Definition#define MAXTIME 1000A simple maxtime is defined, it represents 1000, if it is written inside the programif (IThe compiler replaces the maxtime with 1000 before processing the code.Such a definition looks similar to a normal const definition, but it is also different because t
1. Define a simple constant: Define a constant to facilitate modification. (do not add a semicolon to the end !) # Define n 1000 is equivalent to const int n = 1000, but slightly different, define is just a simple replacement, rather than using it as a quantity. 2. defining simple functions: note that brackets are ofte
Define is a pre-processing command in C language. It is used for macro definition, which can improve the readability of the source code and provide convenience for programming.Pre-processing commands start with "#", for example, include commands # include and macro-defined commands # define. Usually put in front of the source file, which is called preprocessing.Preprocessing refers to the work done before c
A constant is an identifier (first name) of a simple value. As the name implies, the value cannot be changed during script execution (except for the so-called magic constants, they are not constants). Changshime is considered to be case sensitive. Usually, constant identifiers are always uppercase. You can use the Define () function to define constants. After PHP 5.3.0, you can use the Const keyword to
In PHP define () and const () can define constants, then the difference between define () and const exactly where, this many programmers do not understand, I would like to introduce to you some of this function usage ratio.
The difference between define () and const:
Define
Difference between typedef and # define
The benefits of renaming constants using macro definitions: The program is easy to implement and easy to maintain and modify; 1) # define is a pre-processing command that performs simple replacement during compilation and preprocessing without checking the correctness, if the meaning is correct or not, possible errors are discovered and an error is reported only when
1, define--(no parameter macro definition)Usage: The general form is: #define Identifier string(1) "#" means that it is a pre-processing command, usually "#" is the pre-processing command;"Define" defines the command for the macro; "identifier" is the defined macro name; "string" can be a constant, an expression, a string, and so on.(2) In addition to the frequen
# Define usage
1.Simple define Definition
# Define maxtime1000
A simple maxtime is defined. It represents 1000. If you write
If (I
The compiler replaces maxtime with 1000 before processing this code.
This definition looks similar to a normal constant definition const, but it is also different, because the definition of defin
Const is used for the definition of class member constants. it cannot be modified after definition, and define is used to define global constants, so that we can access but cannot change it elsewhere, we will list the details below. note: define cannot be defined in... const is used for the definition of class member constants. it cannot be modified after definit
Usage and difference between typedef and # define
I. Usage of typedef
In C/C ++, typedef is often used to define an alias for an identifier and a keyword. It is part of the language compilation process, but it does not actually allocate memory space, such:
Typedef int;Typedef int array [10];Typedef (int *) pint;
Typedef can be enhancedProgramBut it also has some disadvantages such as "non-intuitive.
A constant is an identifier (first name) of a simple value. As the name implies, the value cannot be changed during script execution (except for the so-called magic constants, they are not constants). Changshime is considered to be case sensitive. Usually, constant identifiers are always uppercase. You can use the Define () function to define constants. After PHP 5.3.0, you can use the Const keyword to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.