test_decl.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <typeinfo>
3 using namespace std;
4 
5 struct Base {
6  virtual ~Base() {}
7  virtual void any() = 0;
8 };
9 struct A : public Base {
10  virtual ~A() {}
11 
12  void a() {
13  cerr << "Hi (a)\n";
14  }
15 
16  virtual void any() {
17  cerr << "Hi from any (a)\n";
18  }
19 };
20 struct B : public Base {
21  virtual ~B() {}
22  void b() {
23  cerr << "Hi (b)\n";
24  }
25 
26  virtual void any() {
27  cerr << "Hi from any (b)\n";
28  }
29 };
30 
31 Base* make_a() { return new A; }
32 Base* make_b() { return new B; }
33 
34 int main()
35 {
36  auto *a = make_a(), *b = make_b();
37  a->any();
38  b->any();
39 
40  typedef decltype(*a) MyA;
41  cerr << typeid(MyA).name() << endl;
42 
43  // decltype(*a)* aa = dynamic_cast<decltype(*a)*>(a);
44 
45  // aa->any();
46  // aa->a();
47 
48 
49  return 0;
50 }
static QCString name
Definition: declinfo.cpp:673
virtual void any()
Definition: test_decl.cxx:16
void a()
Definition: test_decl.cxx:12
Base * make_b()
Definition: test_decl.cxx:32
int main()
Definition: test_decl.cxx:34
STL namespace.
Base * make_a()
Definition: test_decl.cxx:31
virtual void any()
Definition: test_decl.cxx:26
void b()
Definition: test_decl.cxx:22
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
virtual ~Base()
Definition: test_decl.cxx:6
virtual ~B()
Definition: test_decl.cxx:21
virtual ~A()
Definition: test_decl.cxx:10
#define A
Definition: memgrp.cpp:38
static bool * b
Definition: config.cpp:1043
QTextStream & endl(QTextStream &s)