#include <iostream>
using namespace std;
class encapsulation{
private:
int x;
public:
void set(int a){
x=a;
}
int get(){
return x;
}
};
int main() {
encapsulation obj;
obj.set(5);
obj.get();
cout<<obj.get();
return 0;
}
// The variable can be accessed and manipulated only using
// the functions get() and set() which are present inside the class.
// Thus we can say that here, the variable x and the functions get()
// and set() are binded together which is nothing but encapsulation.
To embed this project on your website, copy the following code and paste it into your website's HTML: