-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpointertoSomethingt.cpp
More file actions
139 lines (115 loc) · 1.28 KB
/
pointertoSomethingt.cpp
File metadata and controls
139 lines (115 loc) · 1.28 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using namespace std;
#include<iostream>
//pointer to a class
//static memory
/*
class abc
{
int a,b;
public:
abc(int x,int y)
{
a=x;
b=y;
}
void print()
{
cout<<a<<b;
}
};
int main()
{
abc ob(2,3);
//creating bject
abc *pob;
pob=&ob;
ob.print();
//pointer to a class
pob->print();
return 0;
}
*/
//pointer to a class
//dynamic memory
/*
class abc
{
int a,b;
public:
abc(int x,int y)
{
a=x;
b=y;
}
void print()
{
cout<<a<<b;
}
};
int main()
{
abc ob(2,3);
//creating bject
abc *pob=new abc(2,3);
pob=&ob;
ob.print();
//pointer to a class
pob->print();
return 0;
}*/
//pointer to datamember
//that pointer is mot a member of class
/*
class abc
{
public:int a,b;
abc(int x,int y)
{
a=x;
b=y;
}
};
int main()
{
//pointer pointing to datamember of class
int abc::*pa = &abc::a;
abc ob(2,3);
abc *pob;
pob = &ob;
//four options
cout<<ob.a;
//cout<<pob->a;
//cout<<ob.*a;
//cout<<pob->*pa;
return 0;
}
*/
//pointer to member function
/*
class abc
{
public:int a,b;
abc(int x,int y)
{
a=x;
b=y;
}
void print()
{
cout<<a<<b;
}
};
int main()
{
int abc::*pa = &abc::a;
abc ob(2,3);
abc *pob;
pob = &ob;
void( abc::*point )() = &abc::print;
ob.print();
pob->print();
(ob.*point)();
(pob->*point)();
return 0;
}
*/