Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Enacpsulation_c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// c++ program to explain
// Encapsulation

#include<iostream>
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<<obj.get();
return 0;
}