From Jason Turner

[over.dcl]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1hcmz3nt/{from.md → to.md} +12 -0
tmp/tmp1hcmz3nt/{from.md → to.md} RENAMED
@@ -3,10 +3,12 @@
3
  Two function declarations of the same name refer to the same function if
4
  they are in the same scope and have equivalent parameter declarations (
5
  [[over.load]]). A function member of a derived class is *not* in the
6
  same scope as a function member of the same name in a base class.
7
 
 
 
8
  ``` cpp
9
  struct B {
10
  int f(int);
11
  };
12
 
@@ -24,13 +26,17 @@ void h(D* pd) {
24
  pd->B::f(1); // OK
25
  pd->f("Ben"); // OK, calls D::f
26
  }
27
  ```
28
 
 
 
29
  A locally declared function is not in the same scope as a function in a
30
  containing scope.
31
 
 
 
32
  ``` cpp
33
  void f(const char*);
34
  void g() {
35
  extern void f(int);
36
  f("asdf"); // error: f(int) hides f(const char*)
@@ -44,13 +50,17 @@ void caller () {
44
  callee(88, 99); // error: only callee(int) in scope
45
  }
46
  }
47
  ```
48
 
 
 
49
  Different versions of an overloaded member function can be given
50
  different access rules.
51
 
 
 
52
  ``` cpp
53
  class buffer {
54
  private:
55
  char* p;
56
  int size;
@@ -59,5 +69,7 @@ protected:
59
  public:
60
  buffer(int s) { p = new char[size = s]; }
61
  };
62
  ```
63
 
 
 
 
3
  Two function declarations of the same name refer to the same function if
4
  they are in the same scope and have equivalent parameter declarations (
5
  [[over.load]]). A function member of a derived class is *not* in the
6
  same scope as a function member of the same name in a base class.
7
 
8
+ [*Example 1*:
9
+
10
  ``` cpp
11
  struct B {
12
  int f(int);
13
  };
14
 
 
26
  pd->B::f(1); // OK
27
  pd->f("Ben"); // OK, calls D::f
28
  }
29
  ```
30
 
31
+ — *end example*]
32
+
33
  A locally declared function is not in the same scope as a function in a
34
  containing scope.
35
 
36
+ [*Example 2*:
37
+
38
  ``` cpp
39
  void f(const char*);
40
  void g() {
41
  extern void f(int);
42
  f("asdf"); // error: f(int) hides f(const char*)
 
50
  callee(88, 99); // error: only callee(int) in scope
51
  }
52
  }
53
  ```
54
 
55
+ — *end example*]
56
+
57
  Different versions of an overloaded member function can be given
58
  different access rules.
59
 
60
+ [*Example 3*:
61
+
62
  ``` cpp
63
  class buffer {
64
  private:
65
  char* p;
66
  int size;
 
69
  public:
70
  buffer(int s) { p = new char[size = s]; }
71
  };
72
  ```
73
 
74
+ — *end example*]
75
+