-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice.cpp
97 lines (96 loc) · 1.76 KB
/
practice.cpp
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
//
// Created by Akhilesh Rao on 30-Dec-16.
//
#include <iostream>
#include <iomanip>
using namespace std;
class item{
public:
void sum(int ,int );
};
inline void item::sum(int a,int b){
cout<<a+b;
}
class test{
private:
int a[10];
int i;
public:
void initialize(void){
i=0;
}
void setvalue(int t){
a[i]=t;
i++;
}
void show(void){
int j=0;
for(;j<i;j++){
cout<<a[j]<<setw(5);
}
}
};
class usingstatic{
static int count;
int j=10;
public:
void getdata(int a){
cout<<a<<setw(5);
count++;
}
static void getcount(void){
cout<<count<<endl;
}
};
int usingstatic::count;
// friend int x::fun1();
//class ABC; /------------forward declaration-----------/
//class is just a another type of datatype
//void mul (int ,int) const; /------------constant member function----------------/
//::* /-------pointer to member----------/int A::*ip=&A::m
//derefrancing?
/*
* class m{
* int x,y;
* public:
* void set_xy(int a,int b){
* x=a;
* y=b;
* }
* friend int sum(M);
* }
* int sum(M m){
* int M::*px=&M::x;
* int M::*py=&M::y;
* M *pm=&m;
* int s=m.*px+pm->*py;
* return s;
* }
* int main(){
* M n;
* void (M::*pf)(int ,int)=&M::set_xy; //refrencing to a function of a class
* (n.*pf)(5,20);
* cout<<sum(n)<<endl;
*
* M *op=&n;
* (op->*pf)(2,20);
* cout<<sum(n)<<endl;
*
* return 0;
* }
*/
int main(){
cout<<10<<setw(10)<<15<<setw(10);
item l;
l.sum(5,15);
test t;
t.initialize();
t.setvalue(5);
t.setvalue(10);
t.setvalue(9);
t.show();
usingstatic k;
k.getdata(50);
k.getcount();
return 0;
}