Powered by Blogger.

Encapsulation in C++



Encapsulation in C++

Encapsulation is not C++ programming concept it is Object Oriented Data Hiding is also known as Encapsulation. Encapsulation is the process of combining data and function into a single unit called class. Data Hiding is the mechanism where the details of the class are hidden from the user.

Syntax of Encapsulation

class class name
{
private:
datatype data;
public:
Member functions;
};
main()
{
classname objectname1,objectname2……………;

Example of Encapsulation


class Square
{
private:
int Num;
public:
void Get()
{
cout<<"Enter Number:";
cin>>Num;
}
void Show()
{
cout<<"Square Is:"<<Num*Num;
}
};
void main()
{
Square s;
s.Get();
s.Show();
getch();
}



facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09