Encapsulation

 avatar
narendra
c_cpp
a month ago
239 B
1
Indexable
#include <iostream>
using namespace std;

class ABC{
  int x;
  
  public :
    void set(int n){
    x=n;
  }
  
  int get(){
    return x;
  }
  
};

int main(){
  
  ABC obj1 ;
  obj1.set(5);
  cout<<obj1.get()<<endl;
  
  
  return 0;
}
Leave a Comment