int j = 24;
int main() {
int i = j, j;
j = 42;
}class-key attribute-specifier-seq identifier ;
class-key identifier
typedef unsigned char T; template<class T = T // lookup finds the typedef name of unsigned char , T // lookup finds the template parameter N = 0> struct A { };— end example
namespace N {
int i;
int g(int a) { return a; }
int j();
void q();
}
namespace { int l=1; }
// the potential scope of l is from its point of declaration to the end of the translation unit
namespace N {
int g(char a) { // overloads N::g(int)
return l+a; // l is from unnamed namespace
}
int i; // error: duplicate definition
int j(); // OK: duplicate function declaration
int j() { // OK: definition of N::j()
return g(i); // calls N::g(int)
}
int q(); // error: different return type
} — end example
typedef int c;
enum { i = 1 };
class X {
char v[i]; // error: i refers to ::i but when reevaluated is X::i
int f() { return sizeof(c); } // OK: X::c
char c;
enum { i = 2 };
};
typedef char* T;
struct Y {
T a; // error: T refers to ::T but when reevaluated is Y::T
typedef long T;
T b;
};
typedef int I;
class D {
typedef I I; // error, even though no reordering involved
}; — end example
namespace N {
template<class T> struct A { }; // #1
template<class U> void f(U) { } // #2
struct B {
template<class V> friend int g(struct C*); // #3
};
}
template<class T, T* p, class U = T> class X { /* ... */ };
template<class T> void f(T* p = new T);
template<class T> class X : public Array<T> { /* ... */ };
template<class T> class Y : public T { /* ... */ };typedef int N; template<N X, typename N, template<N Y> class T> struct A;