Академический Документы
Профессиональный Документы
Культура Документы
Islamabad Campus
SESSIONAL 1
CODE
#include <iostream>
class Add{
public:
*/
*/
void ask(){
cin>>num1;
cin>>num2;
*/
return n1+n2;
void show(){
cout<<sum(num1, num2);
};
int main(){
//Creating object of class Add
Add obj;
obj.ask();
obj.show();
return 0;
}
DEV C++
OUTPUT
Write a C++ program to explain the following concepts
1. Data hiding
2. Information hiding
3. Proxy class
CODE
#include <iostream>
struct aproxy {
aproxy(int& r) : mPtr(&r) {}
void operator = (int n) {
if (n > 1 || n < 0) {
*mPtr = n;
int * mPtr;
};
struct array {
int mArray[10];
aproxy operator[](int i) {
return aproxy(mArray[i]);
};
int main() {
try {
array a;
a[0] = 1; // ok
}
}
class Box {
public:
double getVolume(void) {
private:
};
class implementAbstraction
private:
int a, b;
public:
// private members
a = x;
b = y;
void display()
};
int main()
implementAbstraction obj;
obj.set(10, 20);
obj.display();
return 0;
}
OUTPUT