Access Control for objects
<p>Is it Possible to limit the functionality of class to certain objects only (in C++). What that would mean is, suppose there are 10 methods in a class and this class has 10 objects. Is it possible to have object1 &amp; object2 access only 3 functions.
Object3, object4,object5, object6 access 6 functions.
and rest of the objects access all functions?</p>

<p>I am trying to implement an access control system, where general users can see only some limited functionality. Previlaged users can have little bit more access and administrators have access to all functions. </p>

<p>One approach is to use inheritance, something like this:</p>

<p>class PublicFeatures
{ 
    public:</p>

<p>// add some methods here;
};</p>

<p>class ProtectedFeatures:public PublicFeatures
{
   public:</p>

<p>// add some more methods here;
};</p>

<p>class AdminFeatures:public ProtectedFeatures
{
   public:</p>

<p>// add rest of the methods here;
};</p>

<p>In this case, we instantiate objects of any of three classes depending on the kind of access level we want. But what i am thinking is having just one class, and somehow restrict the access to some methods for that particular object.</p>

<p>Is it possible to do such a thing? or i have to follow a different approach for implementing access control?</p>
