1 similarities and differences as constants (0) SameBoth can be used to define constants;#define PI 3.14159//Macro ConstantsConst DOULBE pi=3.14159; Constant(1) different compiler processing methodsThe Define macro is expanded in the preprocessing
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
typedef: Used in computer programming languages to define simple aliases for complex declarations (aliases to types, overall type substitution), and some differences from macro definitions. It is a kind of storage class keyword, and auto, extern,
I 've been away from C/C ++ for a long time. I just saw that I found that the basic skills I 've learned are not clear about # define and typedef ...... Shame !!
1) # define is a pre-processing command. It is a simple replacement during compilation
Type alias. You can also define constants, variables, and compilation switches.
Both of them are the same in some cases.
However, define will be processed during pre-compilation for simple macro replacement. It will be replaced no matter whether
One JavaScript instance per day-determine the region of the web page, and define criptweb
one JavaScript instance per day-determine the area of the web page
How does html jump to another page JavaScript?
Parameters can also be added to
The example explains how to call and define functions in Python, and the example explains python
Call the function:
#! /Usr/bin/env python3 #-*-coding: UTF-8-*-# function call >>> abs (100) 100 >>> abs (-110) 110 >>> abs (12.34) 12.34 >>> abs (1, 2)
# Define n 100000 With this definition, using N in a program represents 100000. Typedef int word4 Give the int A new name word4. (Transfer)StructDifferences from typedef struct It can be divided into three parts:1 first: // Note that C and C +
Usage One: const is used for class member variables, once defined cannot be modified, define is used for global constants, is not used for definitions of class member variables, const can be used in classes or outside classes, define
The use of a typedef
In C/s + + language, a typedef is commonly used to define an identifier and a keyword alias, which is part of the language compilation process, but it does not actually allocate memory space, as in the case of:
typedef int INT;
One, const
1. In the definition of variable
(1) const int a=10;
Description: The defined int type variable A cannot be modified and can only be used. A variable with the Const keyword can be defined as a global variable, but at this point the global
The usage of jssplit is often used to split strings into arrays to facilitate subsequent operations. Today, when I write an advertisement to judge the code, I forgot the usage of split, to facilitate the use of js split, I will not talk about
(Bubble, select, insert, Hill, fast, merge, heap)I worked overtime on the weekend to study c ++ and planned to use C ++ to write Seven classical sorting codes.The previously written C implementation code is debug and runs well.The function
A classic example
The most classic example of using preprocessing and macro definition is to add a header file to avoid the header file being compiled twice. In this case, there is a file headerfile. h. It is included in headerfile1.h and also
C ++ can use const to define constants or # define to define constants, but the former has more advantages than the latter:
1. const constants have data types, while macro constants do not have data types. The compiler can perform static type
The read-only variables defined by const only provide the corresponding memory address from the Assembly perspective, rather than the immediate number as defined by define. Therefore, the read-only variables defined by const areProgramThere is only
After reading some frameworks, many of them use define to define many system parameters at the system core entrance. However, we recently see that some of them are defined in $ _ SERVER and even $ _ ENV. Although all functions can be implemented, I
How should I use PHP to show or use dynamic Constant/Define values? Ex: The following example shows dynamic variables, but how do I use dynamic Constant? The code is as follows:Copy code $ A = 'abc ';$ B = 'a ';Echo $ B; // Print abc?> PHP uses
Set: Unordered. Can not repeat elements.|--hashset: Data structure is a hash table. The thread is unsynchronized.The principle of guaranteeing element uniqueness is to infer whether the hashcode value of an element is the same.Assuming the same, the
Define section:Macros can be used not only in place of constant values, but also in substitution of expressions or even code snippets. (Macros are powerful, but they are also prone to errors, so the pros and cons are quite controversial.) )
The
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.