# define TypeDef const FOR C + + keywords

Source: Internet
Author: User

"#define"

#define是预处理指令, a simple substitution is made during the pre-processing of the compilation without checking for correctness.

"typedef"

A typedef is simply a new name for the identifier to be added for readability

Give an alias to an already existing type within its own scope.

C + + Code
1
2
3
4
5
typedef int *int_ptr;
#define INT_PTR int *

INT_PTR A, B; //int *a,*b;
int_ptr A, b; //int *a,b;

"Const"

C + + Code
1
2
3
4
5
Const int*p;//*p is const
int Const*p;//*p is const

int *Constp;//P is const
Const int *Constp; //*p and P are both const

Const on the left, the *p is a whole, immutable; The const is on the right, p is a whole, cannot be changed.

"#define-TYPEDEF-CONST"

C + + Code
1
2
Const INT_PTR p;   //===>int* const p; (P is const)
Const INT_PTR p;   //===>const int *p; (*p is const)

# define typedef const

for C + + keywords

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.