-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_in_class.cpp
More file actions
65 lines (60 loc) · 1.1 KB
/
Copy pathinput_in_class.cpp
File metadata and controls
65 lines (60 loc) · 1.1 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//Add at end using classes
#include<iostream>
using namespace std;
class Array
{
private:
int *array;
int size;
int filled;
public:
Array()
{
size=13;
array = new int [size];
for(int i=0;i<size;i++)
{
array[i] = i+1;
}
filled=5;
}
Array(int size)
{
this->size = size;
array = new int [size];
filled = 0;
}
void printElement()
{
for(int i=0;i<filled;i++)
{
cout<<array[i]<<"--";
}
cout<<endl;
int getelement(int index)
{
return array[index];
}
int addatend(int element)
{
if(filled<size)
{
array[filled]=element;
filled++;
return true;
}
else
{
false;
}
}
};
int main()
{
Array *array1;
array1 = new Array();
array1->printElement();
array1->getelement(5);
array1->addatend(4);
return 0;
}