|
Home ► Lab Exercise ► Object Oriented Programming Lab Exercise Programs ► CPP Program To Implement Encapsulation▼
CPP Program To Implement Encapsulation |
Alogarithm steps:
- Start the program
- Create the class and declare the data members
- Pass the value for the variables through the function
- Create the object for the class and call the function with arguments
- Compile and execute the program
CPP Program To Implement Encapsulation
#include
class myclass
{
int a, b;
public:
void init(int i, int j);
{
a = i;
b = j;
}
void show();
{
cout<<”a=”<
SAMPLE INPUT AND OUTPUT:
a=10
b=20
|
|
⇓Student Projects⇓
⇑Student Projects⇑
|