Problem Source: http://www.cskaoyan.com/viewthread.php?tid=244542pid=1593533page=1extra= #pid1593533
My answer:First of all, on the structure of the supplement, the domestic classic textbook-Tan Haoqiang's "C + + programming" clearly stated:1, in C language, the definition of the structure of the variable format: struct A;2, in C + +, the definition of the structure of the variable format: a A;In addition, C + + retained the style, that is, C + + can
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
Today, when defining struct, we found that the typedef struct and struct have some differences:
Structure is also a type of data. You can use Structure Variables. Therefore, like other types of variables, you must first define them when using structure variables.The general format for defining structure variables is:St
Chapter One: the difference between typedef struct and struct
1. Basic explanations
A typedef is a C-language keyword that defines a new name for a data type. The data types here include the internal data type (INT,CHAR, etc.) and the custom data type (struct, etc.).
The pur
Three blocks to tell: 1 First://note in C and C + + different Define a struct type in C with typedef: typedef struct STUDENT { int A; }stu; The variable can then be declared: Stu stu1 (if there is no typedef you must use struct
Original: http://www.nowamagic.net/librarys/veda/detail/1785A typedef is a C-language keyword that defines a new name for a data type. The data types here include the internal data type (INT,CHAR, etc.) and the custom data type (struct, etc.).The purpose of using TypeDef in programming is generally two, one is to give the variable a new name that is easy to remem
# 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 ++ are different. To define a struct type in C, use
typedef struct should be a C language design is not very reasonable place, the following explanation is still relatively clear.
Notice different in C and C + +In C, you define a struct type with a typedef:typedef struct STUDENT{int A;}stu;
Stu stu1;
struct Student stu1;
So
struct and typedef structDivided into three pieces to tell:1 First://Note different in C and C + +To define a struct type in C, use a typedef: typedef struct STUDENT{int A;}stu;So when declaring a variable, you can: Stu stu1;
Typedef indicates the type definition. Typedef struct is convenient to use this struct.The specific difference is:If struct node {} is used to define the struct. When applying for a node variable, you need to write it like this, struct
1. First://Note different in C and C + +To define a struct type in C, use a typedef: typedef struct STUDENT{int A;}stu;So when declaring a variable, you can: Stu stu1; (if there is no TypeDef, you must use struct Student stu1;
(1) the well-known use of typedef improves code Portability:
// On the platform that supports long double, the most precise type is real
(2) Use of typedef struct:
Method 1
Struct MSG {
Method 2
Typedef struct message {
Method 3
Divided into three pieces to tell:1 First://Note different in C and C + + to define a struct type in C, use a typedef:typedef struct STUDENT {int A;}stu;so when declaring variables, you can: Stu stu1;if there is no typedef, the struct Student stu1 must be used; declare)The Stu here is actually the alias of the
1 First://Note different in C and C + + to define a struct type in C, use a typedef:typedef struct STUDENT {int A;}stu;so when declaring a variable, you can: Stu stu1; (if there is no TypeDef, you must use struct Student stu1; declare)The Stu here is actually the alias of the st
1. Basic explanation
A typedef is a keyword in the C language that defines a new name for a data type. The data types here include internal data types (Int,char, etc.) and custom data types (struct, etc.).
There are two commonly used typedef in programming, one is to give variables a new name that is easy to remember and meaningful, and the other is to simplify s
StructAnd typedef struct
It can be divided into three parts:1 first:// Note that C and C ++ are different.To define a struct type in C, use typedef: Typedef struct student{Int;} Stu;So when declaring the variable, you can: Stu
1 first:// Note that C and C ++ are different.To define a struct type in C, use typedef: Typedef struct student{Int;} Stu;So when declaring the variable, you can: Stu stu1; (if there is no typedef, you must use struct stud
A typedef is typically used to declare struct-1. Define some memory-friendly structures or make existing types appear more orderly, such as stdint.h that are added to the C + + standard header file later because they are used frequently1typedef signedCharint8_t;2typedef Shortint16_t;3typedefintint32_t;4typedefLong Longint64_t;5typedef unsignedCharuint8_t;6typedef unsigned Shortuint16_t;7typedef unsignedintu
Struct and typedef struct are clear, and structtypedef is clear.
It can be divided into three parts:1 first: // note the differences between C and C ++To define a struct type in C, use typedef:Typedef struct Student{Int;} Stu;So when declaring the variable, you can: Stu stu1
Link: http://www.cnblogs.com/qyaizs/articles/2039101.html
Struct and typedef struct
It can be divided into three parts:1 first: // note the differences between C and C ++To define a struct type in C, use typedef:Typedef struct student{Int;} Stu;So when declaring the variabl
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.