file:/home/vittek/soft/cppexample/main.cpp (Tue Aug 24 20:55:05 2004
) HOME
1: /*
2:
3: This is a simple file demonstrationg how Xrefactory deals with
4: scopes, overloading, virtuals and preprocessor constructions
5: providing 100% correct symbol resolution.
6:
7: Each symbol in this HTML documentation is linked to its definition.
8: Definitions and the first letter of each symbol are linked to
9: complete cross references. In case of ambiguity a special table is
10: generated.
11:
12: */
13:
14: #include "main.h"
15:
16: // A macro which is used only in contexts where 'argc' is
17: // resolved to the same symbol. 'argc' is linked to the definition.
18: #define GET_ARGC() argc
19:
20: // The following 'argc' is ambiguous, because the macro is used in
21: // contexts with different argcs.
22: #define INCR_ARGC() {argc++;}
23:
24: // A macro solving the above problem
25: #define INCR(xxx) {xxx++;}
26:
27: int main(int argc, char **argv) {
28: Infer *arginf = new Infer();
29: Super *argsup = new Super();
30:
31: // Variables, fields, etc are resolved
32: arginf->argc = GET_ARGC();
33: arginf->argv = argv;
34:
35: // Virtual and inherited methods show appropriate class sub-hierarchy.
36: argsup->aVirtualMethod();
37:
38: // Overloaded methods are resolved without ambiguities.
39: // (click on the first letter of the link to get cross-references)
40: arginf->anOverloadedMethod(0);
41: arginf->anOverloadedMethod(0.0);
42: arginf->anOverloadedMethod(anEnumValueX);
43:
44:
45: // An ambiguity is reported here, because of multiple definitions.
46: multiDefVariable = 0;
47:
48: #if SOME_CONDITION
49: // however, no ambiguity occurs here
50: multiDefVariable = 1;
51: #else
52: // nor here
53: multiDefVariable = 1.5;
54: #endif
55:
56: // Ambiguity of the method arises from the ambiguity of 'multiDefVariable'.
57: arginf->anOverloadedMethod(multiDefVariable);
58:
59: // Ambiguity of the method arises from 'condVariable' which itself
60: // does not produce an ambiguity report (as it has only one definition).
61: arginf->anOverloadedMethod(condVariable);
62:
63: INCR_ARGC();
64: INCR(argc);
65: }
66:
67:
68: void Super::anOverloadedMethod(enum anEnum i) {
69: INCR_ARGC();
70: INCR(argc);
71: }
72: void Super::anOverloadedMethod(int i) {
73: INCR_ARGC();
74: INCR(argc);
75: }
76: void Super::anOverloadedMethod(double i) {
77: INCR_ARGC();
78: INCR(argc);
79: }
80:
81: void Infer::aVirtualMethod() {
82: }
83: void Super::aVirtualMethod() {
84: }
85:
86:
Generated by Xrefactory version 2.0.0