forked from cirosantilli/cpp-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypedef.cpp
31 lines (28 loc) · 782 Bytes
/
typedef.cpp
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
#include "common.hpp"
int main() {
// # typedef
{
// It is possible to call constructors with typedefs
{
class C {
public:
int i;
C(int i) : i(i) {}
};
typedef C CTypedef;
CTypedef b = CTypedef(1);
}
// Typdefs inside classes follow public / private scoping.
{
class ClassWithTypedef {
public:
typedef int typedefPublic;
private:
typedef int typedefPrivate;
};
ClassWithTypedef::typedefPublic i;
// ERROR: not accessible from this context
//ClassWithTypedef::typedefPrivate j;
}
}
}