forked from augcampos/asterisk-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht.cpp
More file actions
56 lines (47 loc) · 1.41 KB
/
t.cpp
File metadata and controls
56 lines (47 loc) · 1.41 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
#include <iostream>
#include <stdio.h>
#include <typeinfo>
class Action {
public:
Action() {
}
virtual ~Action() {
}
virtual const std::string& getClassName() {
if (fn.empty()) {
char str [20];
int i;
sscanf((typeid (*this).name()), "%d%s", &i, str);
fn.assign(str, i - 6);
}
return (fn);
//return (__PRETTY_FUNCTION__);
}
private:
std::string fn;
/* data */
};
class TesteAction : public Action {
};
class NovoTesteAction : public TesteAction {
};
int main() {
for (int i = 0; i < 1; ++i) {
Action a;
TesteAction ta;
NovoTesteAction nta;
Action& ra = a;
TesteAction& rta = ta;
Action* pa = &a;
TesteAction* pta = &ta;
std::cout << "Class A[" << a.getClassName() << "]" << std::endl;
std::cout << "Class RA[" << ra.getClassName() << "]" << std::endl;
std::cout << "Class PA[" << pa->getClassName() << "]" << std::endl;
std::cout << "Class TA[" << ta.getClassName() << "]" << std::endl;
std::cout << "Class RTA[" << rta.getClassName() << "]" << std::endl;
std::cout << "Class PTA[" << pta->getClassName() << "]" << std::endl;
std::cout << "Cast TA->A[" << ((Action) ta).getClassName() << "]" << std::endl;
std::cout << "Class NTA[" << nta.getClassName() << "]" << std::endl;
}
return 0;
}