Position:Home>net development> The head file of analytic C /CLI, inside couplet function and array
The head file of analytic C /CLI, inside couplet function and array
From;  Author:Stand originally
Head file and function state

In the design of traditional C and implementation, every sort that you can build a model to needing have a definition, put the definition in respective head file; And in head file, general meeting includes type name, member name, reach function of relevant and small-sized member inside couplet definition.

With the source document that compiles alone individually be will share information to differ through head file, in C /CLI, these informations are shared through program volume. The Point that takes constant give an example kind for, it is compiled alone, made an order part that the name is "Point.dll" . Any applied orders that need some sort definition, must be compiled and link the order part that contains this type, this also asks the program of this DLL form has complete type definition centrally at the same time; Same, the function of all in the type statement also must be defined, otherwise, link implement will report mistake.

E.g. , you can be in Point kind in GetHashCode of statement member function, be in kind outside define it, but must be in same source file (see exemple 1) . But, if put the definition of this member function in an alone source file to be no good however, file of even if source is the input that regards same process as collect, compile at the same time with Point.cpp also be no good, because compile a such files to need to visit program volume Point.dll, and this as it happens is the program volume that this compiles a process to want to generate. (assume here did not use Inline when function is defined, this will discuss at the back. )

Exemple 1:
Public Ref Class Point
{
. . . Virtual Int GetHashCode() Override;
};
Int Point: GetHashCode() Override
{Return X ^ (Y <<1);
}

When compiling volume of order of He Cheng of the replace that reach catenary, implicit do not use head document, and the volume of all and other program that program volume place counts must be to already compiled those who reach a link to pass.

Inside couplet function

In Point, the definition of every member function is written into Inline of purpose (inside couplet) , besides the flexibility that adds a definition, still can carry code in same source file, make member function cannot be defined in the another file besides type definition itself.

Write inside the traditional method of couplet function is state a certain function for Inline, its are right compile implement for it is a clew, let compile implement in proper when undertake to it inside couplet changes processing, be a model change time way with the space. However, use in head file definition inside couplet function, of this kind of form optimize to compiling for, very finite however. When Point kind when compiling, compile implement can be opposite type interior of member function call inside couplet is changed, for example, the Get of all X in Point definition and Y attribute and Set method are met by inside couplet is changed.
Previous12 3 Next