OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.c++/] [member-ptr.cc] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
extern "C" {
2
#include <stdio.h>
3
}
4
 
5
 
6
class A {
7
public:
8
  A();
9
  int foo (int x);
10
  int bar (int y);
11
  virtual int baz (int z);
12
  char c;
13
  int  j;
14
  int  jj;
15
  static int s;
16
};
17
 
18
class B {
19
public:
20
  static int s;
21
};
22
 
23
int A::s = 10;
24
int B::s = 20;
25
 
26
A::A()
27
{
28
  c = 'x';
29
  j = 5;
30
}
31
 
32
int A::foo (int dummy)
33
{
34
  j += 3;
35
  return j + dummy;
36
}
37
 
38
int A::bar (int dummy)
39
{
40
  int r;
41
  j += 13;
42
  r = this->foo(15);
43
  return r + j + 2 * dummy;
44
}
45
 
46
int A::baz (int dummy)
47
{
48
  int r;
49
  j += 15;
50
  r = this->foo(15);
51
  return r + j + 12 * dummy;
52
}
53
 
54
int fum (int dummy)
55
{
56
  return 2 + 13 * dummy;
57
}
58
 
59
typedef int (A::*PMF)(int);
60
 
61
typedef int A::*PMI;
62
 
63
int main ()
64
{
65
  A a;
66
  A * a_p;
67
  PMF pmf;
68
 
69
  PMF * pmf_p;
70
  PMI pmi;
71
 
72
  a.j = 121;
73
  a.jj = 1331;
74
 
75
  int k;
76
 
77
  a_p = &a;
78
 
79
  pmi = &A::j;
80
  pmf = &A::bar;
81
  pmf_p = &pmf;
82
 
83
  pmi = NULL;
84
 
85
  k = (a.*pmf)(3);
86
 
87
  pmi = &A::jj;
88
  pmf = &A::foo;
89
  pmf_p = &pmf;
90
 
91
  k = (a.*pmf)(4);
92
 
93
  k = (a.**pmf_p)(5);
94
 
95
  k = a.*pmi;
96
 
97
 
98
  k = a.bar(2);
99
 
100
  k += fum (4);
101
 
102
  B b;
103
 
104
  k += b.s;
105
 
106
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.