-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cpp
More file actions
executable file
·110 lines (95 loc) · 2.68 KB
/
Test.cpp
File metadata and controls
executable file
·110 lines (95 loc) · 2.68 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
#include <iostream>
using namespace std;
class human{
protected:
string name;
string country;
int age;
human(string name, string country, int age){
human::name = name;
human::country = country;
human::age = age;
cout << "human constructed protected"<<endl;
}
public:
human(){
cout << "human Constructed"<<endl;
}
~human(){
cout << "human Destructed"<<endl;
// cout << "human "<<human::name << " destroyed" << endl;
}
void setname(string n){name = n;}
string getname(){return name;}
void setcountry(string c){country = c;}
string getcountry(){return country;}
void setage(int a){age=a;}
int getage(){return age;}
};
class men:public human{
private:
int strength;
public:
men(int x=10){
cout << "Men Constructed "<<x<<endl;
}
int getage(){
cout<<"\nthis is age"<<endl;
return men::age;
}
int getage(int x){
cout<<"\nthis is age "<<x<<endl;
return men::age;
}
int getage(string k){
cout<<"\nthis is age string "<<k<<endl;
return men::age;
}
~men(){
cout << "Men destructed"<<endl;
}
void setstrength(int s){men::strength = s;}
int getstrength(){return men::strength;}
};
int main(){
human* x = new human();
x->setname("x");
x->setcountry("Egypt");
x->setage(10);
cout << "name : " << x->getname() << " ,country : " << x->getcountry() << " ,Age : " << x->getage() <<endl;
delete x;
men* der_x = new men();
der_x->setname("man white");
der_x->setage(50);
der_x->setstrength(11);
cout << "name : " << der_x->getname() << " ,country : " << der_x->getcountry() << " ,Age : " << der_x->getage("sw") << " ,strength : " << der_x->getstrength() <<endl;
cout << "Point"<<endl;
// Square x = Square();
// cout <<"is instance of "<<(instanceof<Square>(&x) )<<endl;
// cout <<"is instance of "<<(is_base_of<Square,typeof(x)>::value)<<endl;
/*
template<typename Base, typename T>
inline bool instanceof(const T*) {
return is_base_of<Base, T>::value;
}
//references
int i = 10;
int& r=i;
cout<<"i = "<<i<<endl;
cout<<"r = "<<r<<endl;
i=9;
cout<<"rfunc = "<<hamada()<<endl;
time_t now = time(0);
cout<<"time now "<<ctime(&now)<<endl;
tm *gmtm = gmtime(&now);
cout<<1900+(gmtm->tm_year)<<endl;
cout<<1+(gmtm->tm_wday)<<endl;
*/
/*
int& hamada(){
int i= 1210;
int& r = i;
return r;
}*/
return 0;
}