Learning Summary1. If...else ... Semantically it can be used, and other languages are not worse, just remember, one of the furthest distances in the world: I walk if you go else.2, according to individual years of programming experience, too many if...else ... Nesting increases the readability and difficulty of maintaining code. Personally think the code is best not more than three layers if...else ... Nested, otherwise it is best to use a Boolean control process.3, logical operator precedence:!
Learning Summary1, the circulation of the grammar and other languages are not bad, probably most of the language on the basis of the development of C, so much the same is not strange.2, in the judgment expression, only 0 of C language is considered false, all non-0 value positive integers are considered true.1 #include Operation Result:1 is True-1 is True3, the For loop has three expressions, the first expression to initialize the counter, the second expression to express restrictions on the com
represents a name for the requested memory space. Used to represent the value stored by the storage space.Carrots is a variable, that is, the value can be changed.2, line 12th carrots = 25; is an assignment statement that assigns the 25 token to the memory space stored by the carrot. There is a connection assignment concept, such as: A=b=c=3, which assigns 3 to C, assigns the value of C to B, and assigns the value of B to a. is assigned from right to left.3, line 17th carrots = carrots-1; Repre
preprocessor to add the contents of the iostream file to the program. This is a typical preprocessor operation: Replace or add text before the source code is compiled.This raises a question: Why add the contents of the iostream file to the program? The answer involves communication between the program and the outside world. Io in iostream refers to input (information entered into the program) and output (information emitted from the program). The input/output scheme for C + + involves multiple
1. Procedural programming and object-oriented programming2. Abstraction and Class1. Programs that use class objects can access the public part directly, but only through public member functions (or friend functions) to access the private members of the object2. You can define a member function outside of a class declaration and make it an inline function3. Constructors and destructors for classes1. A constructor that accepts a parameter allows an object to be initialized to a value using the ass
Novice C + + when you specify a struct member, you do not know when to use the. operator, and when to use the-I operator.Conclusion: If the structure identifier is a struct name, use the period operator, or if the identifier is a pointer to a struct, use the arrow operator.#include structinflatable{Charname[ -]; floatvolume; DoublePrice ;};intMain () {using namespacestd; intA; Only to keep the DOS interface inflatable*ps=Newinflatable; cout"Enter Name of inflatable item:"; Cin.Get(Ps->name, -
function declares a parameter as a reference or pointer to a const, the parameter cannot be passed to another function unless the latter ensures that the parameter is not modified.40 . What cannot be inherited? constructors, destructors, assignment operators, friend functions.41. can I assign a base class object to a derived class object ? OK!! ① derived classes have a transform constructor: B (const A ), the conversion constructor can accept a type as a base class parameter and other parameter
:\n"); AboutCh=GetFirst (); $ } - - - } A + intGetFirst (void){ the intch; -Ch=GetChar (); $ while(GetChar ()! =Ten) the return 0; the returnch; the}Operation Result:Enter the operation of your choice:A. Add B. SubtractC. Multiply D.divideQ. QuitFPlease enter a right choice:DEnter First Number:QQQQQQ is a number.Please enter a number.such as 2.5, -1.78E8, or 3:1Enter Second number:0Enter a number other than 0:11/1=1.0"C-language learning", C
: Network Disk DownloadThis book is the prestigious C + + Classic tutorial, the content of C + + master Stanley B. Lippman Rich practical experience and the C + + Standards Committee, the former head of Josée Lajoie to the C + + standard in-depth understanding of the perfect combination, has helped countless programmers around the world to learn C + +. A comprehensive and authoritative description of C + + 's basic concepts and techniques, the emphasis on modern C + + programming style makes thi
1. The handling of line breaks when Cin reads errors1#include 2 3 using namespacestd;4 5 intMain () {6 DoubleD;7 CharC;8CIN >>D;9 if(!cin) {Tencout "x"Endl; One cin.clear (); Acout Get() Endl; - } - //cin.get (); theCin.Get(c); -}The above code input is divided into 2 cases:If the input is a double type, cin.get (c) reads the newline character and the program finishes running.If the input is not a double type, such as the char type, then CIN will place the wrong bit, leaving
The first few chapters are relatively simple, so just record the uniqueness.C + + adds the way {} initializes the variable, omitting the = sign so that all types can be initialized in the same way, and that initialization does not allow narrowingThe cout and cin,wchar_t with respect to char have wcout and wcin.The character constants of the wchar_t are prefixed with l, and their length and symbol characteristics are determined by the implementation.c++11 new char16_t (prefix u = character consta
pointer94Finout.write ((Char*) AMP;PL,sizeofPL) //prevent program interruption too late to send out data the if(Finout.fail ()) the { theCerr "Error on attempted write\n";98 exit (exit_failure); About } - 101 //Show revised file102CT =0;103FINOUT.SEEKG (0);//then output everything, position the pointer with the start position104cout "Here is the new contents of the"file the"file:\n";106 while(Finout.read (Char*) AMP;PL,sizeofPL))107 {108cout ": "": "1090) A) pl.population
answer to its calling function.#include 13. The following is a two function prototype:void Show (double ar[], int n); n is the number of elementsvoid Show2 (double ar2[][3], int n); n is the number of rowsA, write a function call to pass the compound text containing the values 8, 3, 9, and 2 to the function shows ().b, write a function call to pass a compound literal containing 2 rows and 3 columns of value to the function Show2 (), where the first behavior is 8, 3, 9, and the second behavior i
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 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.