maybe this has been brought up before by someone else, but I was thinking it might, under some conditions, be useful to have an access level - let's call it secret for now - under which those members declared as secret would only be accessible by the instance that owns them, and not by other instances of the same class. secret static members would only be accessible by static functions.
an example:
Code:
class foo
{
public:
foo() : secretValue(314) // ok
{
}
foo(const foo& rhs) : secretValue(rhs.secretValue) // error
{
}
int GetSecretValue() { return secretValue; }
secret:
int secretValue;
}
what do you all think of this idea? I was thinking it might be a good way to protect resources like network sockets in classes where a given instance owns a particular resoource object.