complete the above type conversion by showing:Things A;................//is initialized and used here. std::stringnm="Book_1"; //display using constructorsintresult=A.compareto (Things (nm));The advantage of Google's C + + specification for explicit is that it avoids outdated types of transformations, which have no drawbacks. So Google agreed that all single-parameter constructors must be displayed, and in rare cases the copy constructor can not declare explicit. For example, a class that is a
conversion constructors (that is, constructors with one parameter) are reciprocal, and if there is a constructor test (int), then it is better to have a conversion operator int (). This eliminates the need to provide object parameter overloading operators, such as test A1 (1); Test A2 (2); Test A3; a3 = A1+A2; Do not need to overload the + operator, because for the A1+A2 operation, the system may first find there is no definition for the test of the + operator, if not, it will look for the test
Keyword: typedefusage: define a new name (alias) for various data typestypedef and BASIC data typestypedef int Integer; Integer a= 8;You can also alias an alias based on thetypedef Integer Myinteger; Myinteger AA = 8;The original data type can also be used normallytypedef and Pointerstypedef Char *String; String str = "stone";typedef and Structural Bodytypedefstruct person Per; // This will not bring up the struct keyword when defining struct variables.Per p; P.name = "xyz";Define and
. There is a part of the in-memory data in the cache, and the CPU is going to operate the cache when the memory is read and stored, without directly manipulating the memory. So multiple CPUs "see" The data in the memory is not the same, this is called memory visibility problem (visibility). Under concurrent programming, a program can have multiple threads running concurrently on different CPU cores, and this time the memory visibility will affect the correctness of the program. In the example, t
Person.h#ifndef oc_person_h#define oc_person_h@interface person:nsobject{ int age; @protected float height;} -(int) age; Get Method-(void) Setage: (int) pAge; Set Method @end#endifPerson.m#import main.mint main () { person* per = [[Person alloc] init]; int age = [per age]; Call the Get method [per setage:16];//Call the Set method //use "." To invoke Get/set using the original variable name, which requires the variable's get, set all conform to the convention int age2 =
outside of the method.Let's look at the following code:
123456789101112131415
publicclassTest {publicstaticvoidmain(String[] args) {MyClass myClass =newMyClass();StringBuffer buffer =newStringBuffer("hello");myClass.changeValue(buffer);System.out.println(buffer.toString());}}classMyClass {voidchangeValue(finalStringBuffer buffer) {buffer.append("world");}}
Running this code will reveal that the output is HelloWorld. Obviously, finishing with final does not prevent chang
Auto local variable (auto Save)Break unconditionally exits the most inner loop of the programSelect an item in the case switch statementChar single-byte integer dataconst defines a constant value that cannot be changedContinue interrupts this cycle and turns to the next cycleDefault selection in the defaults switch statementDo for composing do.....while loop statementsDouble defines the dual-precision floating-point data aElse constituent if.....else Selection Program structureEnum enumextern de
of the classB: Priority and object presenceC: Shared by all objects of the classD: Can be called by the class name:Called by the name of the object, or by the class name, is recommended by the class name.3. Static memory diagram: Static content in the method area4. Static precautions;A: There is no this object in the static methodB: Static can only access static (code tested too)5. The difference between a static variable and a member variableA: Belong to differentStatic variable: Belongs to cl
produces a reference to this, which points to the object itself. If the new object is a subclass object, then there is a super reference inside the subclass object, which points to the parent object inside the current object. So the equivalent of a program inside a this,this point to the object itself, there is a super,super point to the current object inside the parent object.Here is called after overriding the F () method, the first sentence of the method body: "Super.f ();" is to let the par
"#define"#define是预处理指令, a simple substitution is made during the pre-processing of the compilation without checking for correctness."typedef"A typedef is simply a new name for the identifier to be added for readabilityGive an alias to an already existing type within its own scope.
C + + Code
12345
typedef int *int_ptr;#define INT_PTR int *INT_PTR A, B; //int *a,*b;int_ptr A, b; //int *a,b;
"Const"
C + + Code
12345
Constint*p;//*p is
1, Char [tɑ:]Function: Declares a character variable or function English explanation:1) main content characters: a basic data type that accommodates single characters;2) Character type: character (char)2, double [Dbl]Function: declares double-precision variable or function english explanation:1) n. twice times;2) A. twice times, double;3) v. Doubling, brisk walking, redoubling efforts3. Enum [inju:m]function: Declaring enum type English explanation:1) enumeration: Enumeration is a named integer
This article summarizes the Pascal language keywords and reserved words such as the following, for your reference:
absolute//instruction (variable) abstract//instruction (method) and//operator (Boolean) array//type as//operator (RTTI) asm//statement assembler//backward compatibility (assembly) at//statement (Exception handling)
automated//Access category character (Class) begin//block tag case//statement cdecl//function call contract class//Typ
complete step, simple analysis, race + + operation is divided into three steps, a, to get the value of race; b, The value of race is added 1;c, race value is returned. Because of the volatile effect, each time the thread gets the value of race is up to date, but a thread may be suspended after executing a, the other thread completes the race++ operation and writes the value to the main memory, when the thread then executes the B operation, the value of race has expired. , and then write the val
number that displays unmatched rows from file n when connected-onm, connection domain, n is file number, M is domain number-jnm,n is the file number, M is the domain number, and the other domain is used as the connection domain-T, the domain delimiter. The field delimiter used to set a non-space or TAB key.(4) Split commandSplit-output_file_size Intput_filename Output_filenameUsed to split large files into small files.-B N, the size of each split file n-c N, up to n bytes per split file line-l
The roles and differences of the two1. Break: Jump directly out of the current loop body (while, for, do, or block (switch). When the switch case executes, it is bound to match, the match succeeds in returning the value of the current case, and then, depending on whether there is a break, whether to continue the output, or to jump out of judgment (refer to switch introduction).2. Continue: The code after the continue statement in the loop body is no longer executed and the Next loop is performed
= { name: "Bob", showname:function () { alert (this.name); }}; var other = { name: "Tom"}; Someone.showName.apply (); Windowsomeone.showName.apply (other); TomApply is used to change the current object when the function executes, and when there are no parameters, the current object is window and the current object is the parameter when there are parameters. So this example Bob successfully stole Tom's name.New keywordThe this in the constructor after the new keyword
Final: Finally, that's it.In three different situations:1. Decoration classIndicates that the class cannot be inherited and extendedFinal class A {} class extends A {}// Compiler error indicating that it cannot inherit2. Modification methodSubclasses cannot overwrite and override this methodclass a { finalvoid method () {}}classextends A { @ Override void method () {}// compiler Error, unable to override it }3. Modifier variablesFor an object, the reference to the variable is guaran
the object does not exist, so name does not exist.(Non-static access to both static and non-static) 2. The main function is static.public class main{static int data = 9;//static decorated member variable public static void Main (string[] args) { show ();} public void Show ()//here if you want to call, you must use the static modification method, data is not static, called unique data //public static void Show ()//This way can access the static decorated data{ SYSTEM.OUT.PRINTLN (da
Supporting detailed videoThis keyword (master)Understanding this keywordThis use and attention point (master)This constructor overloadFirst, what is this?Second, the principle of the nearest to the use of variablesIn a method, to assign a value to a variable,It will go to the method first to find out if the variableIf so, assign values to the variables inside the method,It's not going to look up.If not, go to the top level and look for it.Third, this memory resolutionIv. the role of thisCode-Sof
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.