sync with my cvs
[nestedvm.git] / src / tests / CXXTest.cc
1 #include <iostream>
2
3 using namespace std;
4
5 class Test {
6 public:
7     Test();
8     ~Test();
9     void sayhi();
10 };
11
12 class Exn {
13 public:
14     Exn() { }
15 };
16     
17
18 Test test;
19
20 int main(int argc,char *argv[]) {
21     printf("Name: %p\n",typeid(const char*).name());
22     printf("Name: %s\n",typeid(const char*).name());
23     printf("Is pointer: %d\n",typeid(const char*).__is_pointer_p ());
24     printf("Name: %p\n",typeid(int).name());
25     printf("Name: %s\n",typeid(int).name());
26     printf("Is pointer: %d\n",typeid(int).__is_pointer_p ());
27     
28     try {
29         test.sayhi();
30     } catch(char *e) {
31         printf("sayhi threw: %s\n",e);
32     } catch(const char *e) {
33         printf("sayhi threw: const char *:%s\n",e);
34     } catch(int n) {
35         printf("sayhi threw: %d\n",n);
36     }
37     return 0;
38 }
39
40 Test::Test() {
41     cout << "Test's constructor" << endl;
42 }
43
44 Test::~Test() {
45     cout << "Test's destructor" << endl;
46 }
47
48 void Test::sayhi() {
49     static char exn[] = "Non-const!";
50     cout << "Hello, World from Test" << endl;
51     cout << "Now throwing an exception" << endl;
52     throw "Hello, Exception Handling!";
53     //throw exn;
54 }