Files Classes Functions Hierarchy
#include <simtemplatedvirtualfunc.h>
Static Public Member Functions | |
| static void | test01 () |
| Demo with visitorPrint function with many types. | |
| static void | test02 () |
| Demo of two templated virtual functions on the same data structures. | |
Static Public Attributes | |
| static string | doc [] |
| Brief description of each test. | |
Definition at line 7 of file simtemplatedvirtualfunc.h.
| void simtemplatedvirtualfunc::test01 | ( | ) | [static] |
Demo with visitorPrint function with many types.
Definition at line 43 of file simtemplatedvirtualfunc.cpp.
References Element::accept().
Referenced by main().
00044 { 00045 ElementA a; 00046 ElementB b; 00047 Element* e; 00048 cout << "Element A derived from Element" << endl; 00049 cout << "Element B derived from Element" << endl; 00050 00051 e=&a; 00052 00053 visitorPrint<int> pr(20); 00054 // cout << pr << endl; 00055 00056 cout << "Let e point to an ElementA object" << endl; 00057 cout << "e->accept(pr)" << endl; 00058 e->accept(pr); 00059 00060 cout << "e->accept( visitorPrint<int>(30) )" << endl; 00061 e->accept( visitorPrint<int>(30) ); 00062 cout << "e->accept(visitorPrint<string>(\"hat mat cat\") )"; 00063 e->accept( visitorPrint<string>("hat mat cat") ); 00064 cout << "Let e point to a ElementB" << endl; 00065 e=&b; 00066 cout << "e->accept(pr)" << endl; 00067 e->accept(pr); 00068 cout << "e->accept( visitorPrint<int>(30) )" << endl; 00069 e->accept( visitorPrint<int>(30) ); 00070 cout << "e->accept( visitorPrint<string>(\"hat mat cat\") )"; 00071 e->accept( visitorPrint<string>("hat mat cat") ); 00072 00073 quat q1(1.0,2.0,-1.0,5.0); 00074 00075 cout << "e->accept( visitorPrint<quat>(q1) ))"; 00076 e->accept( visitorPrint<quat>(q1) ); 00077 //cout << q1 << endl; 00078 00079 00080 }
| void simtemplatedvirtualfunc::test02 | ( | ) | [static] |
Demo of two templated virtual functions on the same data structures.
Definition at line 82 of file simtemplatedvirtualfunc.cpp.
References Element::accept().
Referenced by main().
00083 { 00084 ElementA a; 00085 ElementB b; 00086 Element* e; 00087 00088 quat q1(1.0,2.0,-1.0,5.0); 00089 e=&a; 00090 00091 e->accept( visitorPrint<int>(30) ); 00092 e->accept( visitorPrint<quat>(q1) ); 00093 e->accept( visitorPrint<string>("hat mat cat") ); 00094 00095 00096 e->accept( visitorPrint2<int>(30) ); 00097 e->accept( visitorPrint2<quat>(q1) ); 00098 e->accept( visitorPrint2<string>("hat mat cat") ); 00099 }
string simtemplatedvirtualfunc::doc [static] |
Initial value:
{
"",
"Demo with visitorPrint function with many types.",
"Demo of two templated virtual functions on the same data structures."
}
Definition at line 12 of file simtemplatedvirtualfunc.h.
Referenced by main().
1.5.8