Encapsulation implementation in c++ with bank example


#include<iostream>//Encapsulation in OOP with C++ Language
using namespace std;
class bank{//Class Declaration
private:
         double balance;//Data Member
public://Access Specifier
        void setValue(double b)//Member Function
        {
                balance = b;
        }
        void show(){////Member Function
                cout<<balance<<endl;
        }
};
int main()
{
        bank obj;
        obj.setValue(1000.50);
        obj.show();
        return 0;
}
Youtube link: https://www.youtube.com/watch?v=o7z06_HlSI8&list=PLhGaMw0JdiTKfgMpw6xI1Dh_2RYyPKszj&index=16

No comments:

Post a Comment