-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.cpp
More file actions
43 lines (41 loc) · 699 Bytes
/
array.cpp
File metadata and controls
43 lines (41 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
using namespace std;
class array {
int arr[4];
public:
void set(int index ,int value){
// cout << index << " ";
arr[index]=value;
}
int get(int index){
//cout << "i = " << index << " ";
return arr[index];
}
};
class stack : private array {
private:
int top ;
public:
stack():top(-1)
{}
int pop() {
// cout<<top << " ";
return get(top--);
}
void push(int a) {
++top;
// cout<< "t = " << top << " ";
set(top,a);
}
};
main() {
stack ob;
ob.push(2);
ob.push(4);
ob.push(6);
int a=3;
// cout<<ob.pop() << " shivam " << ob.pop() << " " << ob.pop() << " " ;
cout<<ob.pop()
<< a << " " << ob.pop();;
cout<< " " <<ob.pop();
}