• Tutorials
  • Courses
  • Tracks

q6

Last Updated :
Discuss
Comments

What does this code achieve in terms of encapsulation?

C
class Student {
private:
    int roll;

public:
    void setRoll(int r) { roll = r; }
    int getRoll() { return roll; }
};


Data hiding but no encapsulation


Encapsulation without data hiding

 Both encapsulation and data hiding

 None of the above


Share your thoughts in the comments