The first is struct, in C + +, the structure actually and class have very much similarity. But one difference is that struct is public by default, and class is private.
Of course, the use of struct inheritance is also possible.
The common body is
First, the preface
Looking at the 5th edition of C++primer recently, previously read the 4th edition, but found that the 5th version of the entire knowledge layout and the interpretation of individual knowledge with the 4th version of the
1. Get the address of the array no, because the array name itself is an address
#include int main(void) { char c = 'A'; char cs[] = "ABC"; printf("%c,%s\n",c,cs); /* 获取字符及字符数组的内容 */
1. Variable addresses can be obtained through & variables:
#include int main(void) { int num = 10; printf("变量值: %d\n",num); printf("变量址: %d\n",&num); getchar(); return 0; }
2. A variable that represents a variable address is a
1. The logo of the array is []:
#include int main(void) { int nums[3]; nums[0] = 11; nums[1] = 22; nums[2] = 33; printf("%d,%d,%d",nums[0],nums[1],nums[2]); getchar(); return 0; }
2. Size and dimensions of the array:
#include
1. The result of the operation exceeds the type size:
#include #include int main(void) { short s1 = SHRT_MAX; short s2 = SHRT_MAX; short num1; int num2; /* 不会是期望的值 */ num1 = s1 + s2; printf("%d\n",num1); /* 这样可以了 */ num2 = s1
The variable that gets the type size is best not the int type, but the size_t type;
size_t are defined in stdio.h and stddef.h.
1. Get the size of a known type:
#include #include int main (void){char n = 2;size_t size; size = sizeof
In the C language, the char type is always a byte, and the Double-byte character type is wchar_t;
But it is not a built-in type, defined in Stddef.h.
Assign a value to a character or character array (that is, a string) of type wchar_t to be
整型int可添加short和long: short int:简为short; long int: 简为long; long long int: 简为long long 它们都可以再添加 unsigned: unsigned int: 简为unsigned unsigned short int: 简为unsigned short unsigned long int: 简为unsigned long unsigned long long int: 简为unsigned long
C Language Data type: Basic type, constructed type, pointer type, empty type.
Basic types include: integer, character, floating-point (single, double), enumeration.
The constructed types also include: arrays, structs, and common bodies.
1.
1. General:
#include int main(void) { int i; for (i = 0; i switch (i) { case 1: printf("%d\n", i); break; case 3: printf("%d\n", i); break; case 5: printf("%d\n", i);
1. For the basic form of the loop:
#include int main(void) { int i; for (i=0;i printf("%d\n",i); } getchar(); return 0; }
2. Step Size:
#include int main(void) { int i; for (i=0;i printf("%d\n",i); } getchar();
3.if...elseif statement
The actual application often faces more choice, at this time, will If...else expands, then obtains the IF...ELSEIF structure, its general form is:
if
statement 1
else if
statement 2
else if
2.3.1Integral type ConstantsInteger constants and integer constants. It can be a decimal, octal, hexadecimal numeric integer value. The decimal constants are in the form of:D i g i t sSHere d i g i t s can be one or more decimal digits from 0 to 9,
The normal distribution (norm distribution), as an important distributing law, has a wide range of uses;
Note that the normal distribution contains two parameters, mean (mean) and standard deviation (standard deviation);
Random library (#include ),
The basic operation of single linked listAfter creating a single linked list, what if you want to do something like insert, delete, and so on? So it is necessary to master some of the basic algorithms of single linked list to achieve these
Compound methods (composition) and private inheritance can all represent the form of a new class implemented from a class, by using protected members, and by overriding the virtual function.
Choose the compound method preferentially. Reason:
1.
Class and Object oriented:
Display interface (explicit interface): that is, visible in the source code, you can see all the interfaces of the class in the header file;
Run-time polymorphism (Runtime polymorphism): A member function is virtual,
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