-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp.bak
More file actions
79 lines (74 loc) · 1.69 KB
/
test.cpp.bak
File metadata and controls
79 lines (74 loc) · 1.69 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
//#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <iterator>
#define DEBUG 1;
#ifdef DEBUG
#define T 100
#endif
#define MK(x) std::cout << #x
class String{
char name[20];
int count;
public:
String(char* n){
std::strcpy(name ,n);
count = 0;
}
inline int show_count(){ return count; }
int operator == (String);
int operator ++ (int);
int operator ++();
};
//operator == overloading
int String::operator == (String s){
if(!std::strcmp(name, s.name))
return 1;
return 0;
}
//operator ++ overloading
//postfix
int String::operator ++ (int){
count++;
return count;
}
//prefix
int String::operator ++ (){
count++;
return count;
}
int main(){
/* std::cout<<"\nHello world\n";
std::cout<<T;
int helloworld =1;
std::cout << MK(hello kjgjgb ) << '\n';
std::cout << __TIME__;
std::cout << __DATE__;
std::vector<int> v,v1(2);
std::cout << v.size() << " " << v.capacity() << std::endl;
v.push_back(5);
v.push_back(10);
v.push_back(15);
//std::cout << v[0] << " " << v.size() << " " << v.capacity();
std::vector<int>::iterator i;
std::cout << std::endl << v.max_size() << std::endl;
for( i=v.begin(); i != v.end(); i++){
std::cout << *i << std::endl;
}*/
char a[]="ankit", d[]="dimri";
String s1(a),s2(d);
int temp = 0;
++s1;
temp = ++s1;
++s1;
++s1;
temp = s1++;
s1++;
std::cout << s1.show_count() << std::endl << temp << std::endl;
if(s1 == s2)
MK(both strings are same);
else
MK(both strings are not same);
return 0;
}