File: c1.h

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20090918-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 117,308 kB
  • ctags: 410,601
  • sloc: cpp: 1,883,007; ansic: 17,279; sh: 2,190; makefile: 1,088
file content (77 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (5)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef __C1_h__
#define __C1_h__

#include <stdio.h>

class M {
  int i;
public:
  M() { i = 815; };
  M(const M&c) { i = c.i; }
  int val () const { return i; }
};

template <typename T> class TemplateBase {
};

class Unique {
    int _id;
    void gen () {
	static int curr = 0;
	_id = curr++;
    }
 public:
    Unique () { gen (); }
    Unique (const Unique &obj) { gen (); }
    int id () const { return _id; }
};

// the TemplateBase is only handled correct with --real-instances
class C1 : TemplateBase<int>, Unique {
  // these elements should not be copied!
  friend class M;
  enum E { E1 = 10, E2 };
  static const int c = 13;
  // --
  M m;
  M ma[3];
  const int &r;
  const int val;
  double array[2];
  unsigned scalar;
  static char *static_ptr;
  int a1[3], s1;
  int s2, a2[6];
  typedef int INT[10];
  int s3, a3[4][6], s4;
public:
  C1 (int v) : val (v), r(val) { 
    array[0] = 3.14; array[1] = 2.71;
    scalar = 4711;
    dump ();
  }
  inline C1 (double);
  ~C1 () {}
  void dump () const {
    printf ("C1 obj %d (%d, [%d, %d, %d], %d, %d, %d, [%1.2lf, %1.2lf] %d)\n",
	    id (),
	    m.val (),
	    ma[0].val (), ma[1].val (), ma[2].val (),
	    r,
	    val,
	    c,
	    array[0], array[1],
	    scalar);
  }
};

char *C1::static_ptr = (char*)0; // this cast creates an anonymous attribute!

inline C1::C1 (double d) : val (-1), r (val) {
  array[0] = d + 1.0;
  array[1] = d + 2.0;
  scalar = 4712;
  dump ();
}

#endif // __C1_h__