Learning Summary1. The C base data type uses 11 keywords: int, long, short, unsigned, char, float, double, signed, _bool, _complex, and _imaginary.2. In standard C, integer 0 is false, and integers greater than 0 are true. Char can actually be printed as an integer.3, octal is prefixed with 0, hexadecimal is expressed in 0x or 0X.4, can use the sizeof keyword query type length, if sizeof (int). C99 has a portable type (inttype.h): int16_t, unint32_t, etc., mainly for code portability.5, Programm
use the Const keyword, such as the const int months=12. Then months is a constant. In short, the const -Modified object is constant and cannot be modified.6, Programming exercises (title 7):1#include 2 #defineJ2s 3.7853 #defineY2G 1.6094 intMain () {5 DoubleMile,gallon;6printf"Enter your mile:");7scanf"%LF",mile);8printf"Enter your gallon:");9scanf"%LF",gallon);Tenprintf"your oil wear is%.1f\n", mile/gallon); Oneprintf"your CHN oil wear is%.1f\n", mile*y2g/(gallon*j2s)); A}Operation Re
C + + Primer Plus chapter 12th-Dynamic memory and classes, copy constructors
1 The class declaration does not allocate storage space for the string itself, but instead uses new in the constructor to allocate space for the string. This avoids the predefined length of the string in the class declaration.
2 static members have a feature that no matter how many objects are created, the program is only creating
the C language, most statements end with a semicolon.A declaration statement specifies a variable name for a variable and identifies the data type stored in the variable, which is an identifier.An assignment expression statement assigns a value to a variable, which assigns the value to the storage space.The function expression statement is used to invoke the specified named function, and when the calling function finishes executing, the program returns to the statement following the function ca
;} Complex Complex::operator+(ConstComplex A)Const{Complex temp; Temp.real= Real +A.real; TEMP.IMGN= IMGN +A.IMGN; returntemp; /*return Complex (real + a.real, IMGN + A.IMGN);*///calling constructors directly//be accustomed to using this simplified statement//In general, the last statement, equivalent to the previous three, call the constructor will produce a temporary object, assigned to the left}complex Complex::operator-(ConstComplex A)Const{Complex temp; Temp.real= Real-A.real; TEMP.IMGN=
when a data item uses two or more types, but not both. Of course, the union size is the largest member of its storage.For enumeration types, only the enumerator used when defining the enumeration can be assigned to this enumeration variable without casting.enum Spectrum {Red,orange,yellow,green,blue};spectrum band=Blue;// ValidSpectrum Band2=2//Invalid, 2 not an EnumeratoAn enumeration type is defined only by an assignment operator, and an enumeration can be promoted to an int type, but an int
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.