C++ Properties

PHOTO EMBED

Thu Jun 30 2022 13:55:40 GMT+0000 (Coordinated Universal Time)

Saved by @Marcos_ #cplusplus

__declspec( property (put=setFunction, get=getFunction) ) data-type property-name; 
content_copyCOPY

The above code allows us to tell Visual C++ that we want setFunction to be called every time property-name is assigned to. Conversely, we want getFunction to be called every time we need to get the value of property-name. Of course, we still have to define those member functions, but this brings us much closer to implementing C#-style properties.

https://www.codeproject.com/Articles/118921/C-Properties