[ create a new paste ] login | about

Link: http://codepad.org/lthoZivn    [ raw code | output | fork ]

C++, pasted on Aug 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

class A {
enum { value=1 };       // private
};

template <int i>        // bug appears only if B is a template
struct B {
 enum { value=A::value }; // <- silently access private member
};

int main() {
  std::cout << B<1>::value << std::endl;
  return 0;
}


Output:
1
1


Create a new paste based on this one


Comments: