class type_class {
int field1;
int field2;
type_class (int f1, int f2) {
field1 = f1;
field2 = f2;
}
}
const type_class var(12, 34);
$ cat > test.cpp <<EOF
class type_class {
int field1;
int field2;
public:
constexpr type_class (int f1, int f2): field1(f1), field2(f2) {
}
};
extern const type_class var;
const type_class var(12, 34);
EOF
$ g++ -S -O2 test.cpp
$ cat test.s
.file "test.cpp"
.globl var
.section .rodata
.align 8
.type var, @object
.size var, 8
var:
.long 12
.long 34
.ident "GCC: (Debian 6.3.0-18+deb9u1) 6.3.0 20170516"
.section .note.GNU-stack,"",@progbits
template< int X, int Y >
class NAME
{
public:
enum { field1 = X, field2 = Y };
};
typedef NAME<5,7> Name57;
int a = Name57::field1;
int b = Name57::field2;