-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_pointers.cpp
More file actions
56 lines (48 loc) · 1014 Bytes
/
C_pointers.cpp
File metadata and controls
56 lines (48 loc) · 1014 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
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <fstream>
#include <iostream>
#include <conio.h>
#include <cmath>
using namespace std;
class C_pointers
{
private:
int age;
string name;
char g = 'A';
public:
void getData()
{
cout << "My name is "<< name;
cout << " my age is "<< age;
cout << " lucky number is "<< g;
}
void setData(string na, int ag, char sdv)
{
name = na;
age = ag;
g = sdv;
}
};
int main()
{
C_pointers cp;
C_pointers *ptr=new C_pointers[5];
ptr->setData("amad", 21, 'a');
ptr->getData();
cout<<endl;
ptr->setData("saad",23,'s');
ptr->getData();
cout<<endl;
ptr->setData("jawad",12,'j');
ptr->getData();
// pointer in c++
cout<<endl;
int a = 123;
int *b = &a;
int **c;
c = &b;
delete &a;
cout << &a << " " << a << " " << &b << " " << b << " " << *b << endl;
cout << c << " " << *c;
return 0;
}