Difference between typedef and define
The following code is used to describe
Typedef char * typedef_char;# Define define_char char * // No semicolon here
Void main (INT argc, char * argv []){Char s [] = "ASDF ";Const typedef_char P = s; // char * const* P = 'B'; // The P pointer is a constant pointer. It cannot point to anything else, but the content to which it points can be changed.
Cout
Const define_c
In general, we define a constant using # define, #define的本质是文本替换, for example, # define INT_PTR int*, when we use a int_ptr,int_ptr a, B, which is equivalent to an INT * A, A, a, b; That is, define a pointer variable A and integer variable B, which is a common scenario for #
1 NO parameter macro definitionThe macro name of the parameterless macro is not followed by a parameter.The general form of its definition is:#define Identifier stringWhere the "#" indicates that this is a preprocessing command. All that begin with "#" are pre-processing commands. "Define" defines the command for the macro. "Identifier" is the name of the macro defined. A "string" can be a constant, an expr
Note: Define cannot be defined in a class, and the const must be defined in a class, and the const must be accessed by the class name:: Variable name
1. Const is used for class member variable definition once defined and cannot change its value. Define defines global constants that can be accessed anywhere.2, define can not be defined in the class and Const.3. C
1) #define是预处理指令, in the compilation preprocessing simple substitution, does not make the correctness check, does not have the meaning whether correctly still to carry in, only has in the compilation has been expanded the source program only then discovers the possible error and errors. Like what:#define PI 3.1415926In the program: Area=pi*r*r will be replaced with 3.1415926*r*rSuppose you write the number
1) #define是预处理指令, in the compilation preprocessing simple substitution, does not make the correctness check, does not have the meaning whether correctly still brings in, only when compiles the already expanded source program only then discovers the possible error and error. For example:#define PI 3.1415926In the program: Area=pi*r*r will be replaced with 3.1415926*r*rIf you write the number 9 in the #
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
1 :__ file __,__ line __, macro expanded, Middle Layer Macro
_ File _ is the predefine macro of the compiler, indicating the absolute path of the file, but ASCII characters.
Suppose you want to convert _ file _ into a wide character.
Maybe you want
# DEFINE _ wfile _ L ##__ file __
Wchar_t pszfilepath [] =__ wfile __;
In this case, the compiler will prompt that "l1_file _" is an undeclared identifier.
Why?
If the parameter after # Is a macro, # will
Original article address:
Http://blog.csdn.net/kindazrael/article/details/8108868
In C, Preprocessor is a powerful tool that makes your code easier to read and modify. With preprocessing code, you can redefine a part of the code to make your code more suitable for your style. Preprocessor is processed in advance before the code is compiled. The pre-processing code starts with a pound sign.1. About
#define
#defineDeclarations are mainly used to assign
#define宏定义在C系开发中可以说占有举足轻重的作用. The underlying framework does not have to say, in order to compile optimization and convenience, as well as cross-platform capabilities, macros are heavily used, it can be said that the bottom of development left define will be unable to move. When developing at a higher level, we put more emphasis on business logic and seem to have little use and reliance on macros.But the ben
Reference:typedef usage Http://www.cnblogs.com/ggjucheng/archive/2011/12/27/2303238.html#define用法: http://blog.csdn.net/benny5609/article/details/2314541====typedef=====There are generally two uses for typedef: one is to give the variable a new name that is easy to remember and makes sense, and the other is to simplify some of the more complex type declarations.egtypedef int size;typedef unsigned int WORD;typedef with arrays, pointersGeneral Array Dec
Original address: http://www.manongjc.com/article/491.html
Const is the definition of a class member constant, which cannot be changed after the definition, and define we define global constants so that we can access them elsewhere but not change them.
Note: Define cannot be defined in a class, and a const must be defined in a class, and the const must be access
// ================================================ ========================================// Title:// How to Write elegant code (2) -- # define? Const? Or enum?// Author:// Norains// Date:/// Tuesday 21-July-2009// Environment:// Wince5.0 + vs2005// ================================================ ========================================
# Define, const, and Enum: What are the associations between the thr
1. Simple macro definition
#define Identifier substitution list (alternate list can be number, string literal, punctuation, operator, identifier, keyword, Word constants quantity.) Note: The substitution list is nullable.
Typical error:
#define N = 100
int a[n]; /* This will become an int a[= 100], which will be processed as an identification mark.
#define N
# 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, you often cannot understand the essence of the command, and there is always some confusion here. The command is misused during programming, so that the running of the program is inconsistent with the expected pu
1. Define a simple constant: Define a constant to facilitate modification. (do not add a semicolon to the end !)
# Define n 1000
It is equivalent to const int n = 1000, but slightly different. Define is a simple replacement instead of a quantity.
2. Define simple functions:
1. Simple define Definition# Define maxtime1000A simple maxtime is defined. It represents 1000. If you writeIf (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 define is more like a simple text replacement, rather than bei
Original article address:
Http://blog.csdn.net/kindazrael/article/details/8108868
Objective-C: # define Usage Analysis
In C, Preprocessor is a powerful tool that makes your code easier to read and modify. With preprocessing code, you can redefine a part of the code to make your code more suitable for your style. Preprocessor is processed in advance before the code is compiled. The pre-processing code starts with a pound sign.1. About
#
Asynchronous modules define AMD and asynchronous modules amd
It is called Asynchronous Module Definition, and is defined by Asynchronous components (or modules. AMD is a mechanism in which components and their dependencies can be asynchronously loaded.Define Method
define(id?, dependencies?, factory);
Component ID
The component ID is the unique identifier of a component. In a script file that is one-to-one
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.