Well, it's an entry level. It's a collection of small issues and easy-to-be-ignored things I 've made when learning this book.
At the same time, he expressed contempt for the predecessor who invented the notebook touchpad.
I am stupid. I have made a lot of problems before, but I am slow at sorting out ...........
I will review C primer plus and prepare for the next step of in-depth study of C language and d
("Your work time is%d\n", time);printf ("salary=%.1f tax=%.1f\n", salary,tax);Break ;Case 2:printf ("Input your Work time:\n");scanf ("%d", time);salary=calculate_salary (TIME,LEVEL2);Tax=calculate_tax (salary);printf ("Your work time is%d\n", time);printf ("salary=%.1f tax=%.1f\n", salary,tax);Break ;Case 3:printf ("Input your Work time:\n");scanf ("%d", time);salary=calculate_salary (TIME,LEVEL3);Tax=calculate_tax (salary);printf ("Your work time is%d\n", time);printf ("salary=%.1f tax=%.1f\n
1. How do I address the basic module of C?The C language contains one or more functions, and they are the basic modules of C.2. What is a syntax error and what is a semantic error?Grammatical errors are made by non-adherence to the grammar rules of the C language, and semantic errors are errors in meaning.3. Which of the following is the C keyword: main int function char =int Char4. Write a program that can produce the following output:smile! smile! smile!smile! smile!smile!Defines a string that
statements can be divided into 4 types: Declaration Statements, assignment statements (Assignment statements are special cases of expression statements), function statements, structured statements.4. Type conversionBasic rules for type conversions: 1. When the expression has char and short types, it is automatically converted to int and, if required, automatically converted to unsigned int. Under Kr C, float is automatically converted to double. 2. In any operation that contains two data types,
concept of a function from multiple parts. 4. One line.The third example code in the book is as follows#include "stdio.h" Void Butler (void); /* Iso/ansi C function prototype */int main (void) { printf ("I'll summon the butler funtion.\n"); Butler (); printf ("Yes, bring me some tea and writeable cd-roms.\n"); return 0;} void Butler (void) { printf ("You Rang, sir?\n");}The C90 standard adds a prototype, which is a declarative form that tells the compiler that you are using a spe
program to test the function.#include 5. Write a function. The visit function accepts the following parameters: the name of an int array, the size of an array, and a value that represents the number of picks. The function then randomly selects the specified number of elements from the array and prints them. Each element is selected at most once (draw or select a jury member). Also, if your implementation supports time () (described in the 12th chapter) or other similar functions, the output of
1. Print short, long, long long and unsigned#include intMainvoid) {unsignedintUN =3000000000; ShortEnd = $; LongBig =65537; Long LongVerybig =12345678908642; printf ("un =%u and not%d\n", UN, un);//U=udprintf"end =%hd and%d\n", end, end); printf ("big =%ld and not%hd\n", big, big); printf ("Verybig=%lld and not%ld\n", Verybig, Verybig); return 0;}Conclusion: Even if the variable itself is an unsigned type, you need to add u when printing, otherwise print according to the signed type; If you pri
templates:Template Class Trophy {...};where z is an int value, U is the type name, CL is a class template that uses TemplateClass templates can be partially materialized:Template Template Template The first declaration, which has the same two types, and a value of N of 6, creates a materialization. Similarly, the second declaration creates a materialization of the case where n equals 100, and the third declares that the second type is a pointer to the first type, creating a materialization.Temp
""P to process a PO, or Q to quit.\n"; } cout"bye\n"; return 0;}Effect:Please enter a to add a purchase order. P to process a PO, or Q to quit. Aenter a PO number to add:moonlightpoetplease enter a to add a purchase order. P to process a PO, or Q to quit. Aenter a PO number to add:moonlitplease enter a to add a purchase order. P to process a PO, or Q to quit. PPO #moonlit Poppedplease Enter a to add a purchase order. P to process a PO, or Q to quit. PPO #moonlightpoet Poppedplease Enter a to add
() !='\ n') Continue;}voidSinger::show ()Const{cout"category:singer\n"; Worker::show (); cout"Vocal Range:"Endl;}Listing 14.9 is a short program that tests these classes using a multiple array of pointers.Program Listing 14.9 Worktest.cpp//worktest.cpp--Test worker class hierarchy#include #include"worker0.h"Const intLIM =4;intMain () {Waiter Bob ("Bob Apple",314L,5); Singer Bev ("Beverly Hills",522L,3); Waiter W_temp; Singer s_temp; Worker* Pw[lim] = {bob, bev, w_temp, s_temp}; i
called first and then the accumulated destructor is called.If you want to use a class as a base class, you can declare members to be protected, not private, so that derived classes will have direct access to those members. However, using private members can often reduce the likelihood of programming problems. If you want a derived class to redefine a method of a base class, use the keyword virtual to declare it as virtual. This allows objects accessed through pointers or references to be handle
the type of PG can be safely converted to superb*, if possible, return the address of the object, otherwise, return a null pointer.Dynamic_casttypeID makes it possible to determine whether two objects are of the same type and accepts two parameters: the class name and the expression that the result is an object. The return value is a reference to the Type_info object.typeID (Magnificent) ==typeid (*PG);A null pointer to PG throws an exception Bad_typeid. Type_info contains the name () function,
Procedural programming and object-oriented programmingObject-oriented Programming (OOP) Features:
Abstract
Encapsulation and data hiding
Polymorphic
Inherited
Reusability of code
Abstractions and classesA class is a C + + tool that translates abstractions into user-defined types, which synthesize a concise package of data representation and manipulation of data.Constructors and destructors for classesConstructor: Same as class nameDestructor: ~ Class nameObject Initialization
1. What is the role of #include This compilation instruction causes the preprocessor to add the contents of the iostream file to the program, which is a typical preprocessing operation that replaces or adds text before the source code is compiled.Io in iostream refers to input and output, and the input/output scheme in C + + involves multiple definitions in a iostream file, in order to display messages using cout, the first program needs these definitions, #include The compile instruction causes
Fifth cycle and relationship expressions1.2. Category aliases:(1) #define Float_pointer FLOAT *Float_pointer PA, PB; Preprocessor substitution converts the declaration into a float * pa, PB;//PA is a pointer, PB is a float(2) typedef char BYTE does not appear above the problem is the best choice3, Cin.get (name, arsize). Get ()//Enter a name with a length of arsize to accept line breaksThe input sent to CIN is buffered. This means that only the user presses the carriage return and the content th
characteristics.16.4.2 iterator TypeThe STL defines five types of iterators: an input iterator, an output iterator, a forward iterator, a bidirectional iterator, and a random iterator.16.4.3 iterator Hierarchy......16.4.4 concepts, improvements and models......16.4.5 container TypeThe previous 11 container types were: Deque,list,queue,priority_queue,stack,vector,map,multimap,set,multiset,bitsetC + + has new forward_list,unordered_map,unordered_multimap,unordered_set,unordered_multiset and does
{' L ', ' I ', ' s ', ' P '};16.1.2 String Class inputFor C-style strings, there are 3 ways to enter:Char info[100];CIN >> Info; Read a WordCin.getline (info, 100); Read a line, discard \ nCin.get (info, 100); Read a line, leave \ n in queueFor string objects, there are two ways of doing this:string stuff;CIN >> Stuff; Read a WordGetline (cin, stuff); Read a line, discard \ nTwo versions of Getline () have an optional parameter that specifies which character to use to determine the bounds of th
the container has an iterator concept that supports the algorithm requirements. For example, the For_each () algorithm uses an input iterator, and all STL container class types meet their minimum requirements: while sort () requires a random-access iterator, not all container classes support this iterator. If the container class does not meet the requirements of a particular algorithm, it may provide a dedicated method. For example, the list class contains a sort () method based on a bidirectio
assigned to a unique_ptr in the VP. In addition, if you pass an object by value instead of by reference to show (), the For_each () syntax will be illegal because this will cause the pi to be initialized with a non-temporary unique_ptr from the VP, which is not allowed. In front of the state, the compiler will find an attempt to use unique_ptr incorrectly.When Unique_ptr is the right value, it can be assigned to shared_ptr, which is the same as assigning one unique_ptr to another that needs to
calling function.A class is a user-defined data type specification that describes in detail how information is represented and what operations can be performed on the data. An object is an entity created from a class specification, just as a simple variable is an entity created from a data type description.C + + provides two predetermined objects (CIN and cout) for processing inputs and outputs, which are instances of the IStream and Ostream classes that are defined in the iostream file. The in
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.