Warning: Trying to access array offset on value of type null in /home/u623081920/domains/hindilearn.in/public_html/tutorials.php on line 241

Warning: Trying to access array offset on value of type null in /home/u623081920/domains/hindilearn.in/public_html/tutorials.php on line 244
Encapsulation In Hindi - C++ Programming - Hindilearn

आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
C++ - Encapsulation

Introduction for Data Encapsulation

Data Encapsulation का इस्तेमाल हर program में किया जा सकता है | OOP में ये काफी महत्वपूर्ण feature है |

Data Encapsulation में Object के methods और data को एक ही जगह पर मतलब एक ही class पर store करके रखा जाता है |

Data Encapsulation में class के data members और member function को एक ही class में define किये जाते है | Data Encapsulation ये Data Abstraction का भी एक अच्छा उदाहरण है |

ये object की सारी information एक ही जगह पर bind करके रखी जाती है |

Source Code :
#include <iostream.h>
using namespace std;

class A{
    int a, b;

public:
    A(){
    cout<<"Enter two Numbers"<<endl;
    cin>>a>>b;
}
    void display(){
    cout<<"Addition of "<<a<<" and "<<b<<" is "<<a+b<<endl;
    cout<<"Subtraction of "<<a<<" and "<<b<<" is "<<a-b<<endl;
    cout<<"Multiplication of "<<a<<" and "<<b<<" is "<<a*b<<endl;
    cout<<"Division "<<a<<" and "<<b<<" is "<<a/b<<endl;
}
};
int main(){

A obj;
obj.display();
return 0;
}
Output :
Enter two Numbers
12
6
Addition of 12 and 6 is 18
Subtraction of 12 and 6 is 6
Multiplication of 12 and 6 is 72
Division 12 and 6 is 2