diff --git a/Enacpsulation_c++ b/Enacpsulation_c++ new file mode 100644 index 0000000..797eab0 --- /dev/null +++ b/Enacpsulation_c++ @@ -0,0 +1,38 @@ +// c++ program to explain +// Encapsulation + +#include +using namespace std; + +class Encapsulation +{ + private: + // data hidden from outside world + int x; + + public: + // function to set value of + // variable x + void set(int a) + { + x =a; + } + + // function to return value of + // variable x + int get() + { + return x; + } +}; + +// main function +int main() +{ + Encapsulation obj; + + obj.set(5); + + cout<