Software> Developer Network> Microsoft Development Column> Visual Studio.net Column> VC.NET> Text News Displays the C / CLI of the European Computer Developer Association (a different C language, it is convenient for developers in Microsoft The program is more easily developed under the .NET framework) Language in the C language extension. The purpose of writing this article is not to recommend that standard C includes this part of the expansion, nor is the recognition of C / CLI, but only explores the development direction of the C / CLI language in this area. I. The attribute in the Basics C / CLI is a operable entity similar to a variety of data members (having various operational restrictions), but this operation is often converted to the call access function (this is mainly "getter" and "" Setter "function). E.g:
Struct demo1 {Property Int Val {// A very simple integer, hierarchical property. INT get () const { demo1 :: access_count; return1-> value;} void set (int V) { demo1 :: access_count; this-> value = v;}} private: int value; static unsigned Long access_count;}; int main () {DEMO1 D; D.VAL = 3; // Call the "SET" operation function. Return D.val; // Call the "GET" function. }
The name of the access function must be a GET or a SET function, and any of the two can be omitted, but it must not be omitted in both. An access function is omitted results in only one read attribute or only one write property. The address of the attribute is unable to obtain, however, the access function can be used as a member function to produce a pointer constant to the member (eg & demo1 :: val :: set).
Properties can be declared using keyword "Virtual", which is the objective function function, and the pure virtual property function may exist, for example:
Struct VirtualProp {Virtual Property Int Val = 0 {INT GET () const; // pure virtual function. Virtual void set (int V); // pure virtual function, here keyword "Virtual" is redundant. } // ...};
The above example shows some simple, non-static, hierarchical attribute examples that are usually encountered. The C / CLI document contains a lot of concept changes, which will be explained below.
Full text reading: Property exploration of C / CLI language