Smart EducationLEARN • DISCOVER • SHARE
☰

Article

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

Get in touch

Questions about learning resources, collaboration or research? Send a message.

Contact us-desc:Feel free to contact me at anytime

Name

Email *

Message *