Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the specific concept of C++ attribute

Shulou Source: shulou.com Published: 2022-06-02 22:38:15 10月23日 Update

What this article shares with you is about how to understand the specific concepts of C++ attributes. The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.

The attribute in C++ programming language is a relatively basic knowledge concept, we beginners need to have a deep understanding of this basic knowledge in the process of learning, in order to facilitate future application. Let's take a look at the related concepts of C++ attributes here.

"_ _ declspec" is a special keyword in Microsoft C++. It can be extended to Standard C++ with some attributes. These C++ attributes are:

Align, allocate, deprecated, dllexport, dllimport, naked, noinline, noreturn, nothrow, novtable, selectany, thread, property and uuid.

Template

< class T1, class T2>

Class KeyValuePair {private: / /-- Parameter T1 * Key; / /-value T2 * Value; public: KeyValuePair () {Key=new T1; Value=new T2;} ~ KeyValuePair () {delete Key; delete Value;} public: T1 GetKey () {return this- > Key;} T1 SetKey (T1 inputKey) {this- > Key=inputKey;} private: int m_old Public: / /-- attribute-get-set- returns data-C++ attribute name _ declspec (property (get=GetOld,put=SetOld)) int Old; int GetOld (void) {return masked value;} void SetOld (int value) {masked oldvalue;}}; int main (int argc, char* argv []) {KeyValuePair

< int,int>

C1; c1.Oldstone 123; cout < < c1.Old;} above is how to understand the specific concept of C++ attributes. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Attributes Clearing skills concepts knowledge basics more articles learning practical technical secondary schools keywords keywords beginners parameters names basics that is work sessions data articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi OPPO Reno Shulou Information Microsoft