Encapsulation (it is a process of Data Hiding and protect your data and Get or Set Value using Getter and Setter Function )
class TestClss {
private:
int a;
protected:
int b;
public:
int c;
void SetValue(int a) {
this->a = a;
}
int GetValue() {
return a;
}
};
int main() {
////ABC obj;
//B obj;
// a=10 b=20,c=30;
TestClss obj;
obj.SetValue(10);
obj.c = 30;
cout << "A=" << obj.GetValue()<< endl;
cout << "C=" << obj.c<<endl;
return 0;
}
Comments
Post a Comment