I discovered a neat feature years ago while i was searching something on google. It enabled the usage of a sort of "function" to control access to a member variable but i can't seem to find it anymore. (I am also not sure if this was a c++ feature or only specific to the msvc compiler because it was highlighted red in visual studio as if it was label or something)
The theory behind it was something similar to this:
class A
{
public:
.test(int value)
{
priv = value;
}
private:
int priv = 0;
};
...
A a;
a.test = 14; // Sets priv to 14 ! note no () needed after test´
Does anybody know what it is / was?
Thank you everyone for responding but no, it was not C# like some people desperately tried to tell me.
Microsoft docs - property (C++)
For those interested how it worked:
struct S
{
int i;
void putprop(int j) {
i = j;
}
int getprop() {
return i;
}
__declspec(property(get = getprop, put = putprop)) int the_prop;
};
S s;
s.the_prop = 5;
int test = s.the_prop;