#include <iostream>
using namespace std;
struct test {
// 宣言
static const int a = 0xAA;
static const int b = 0xBB;
static int c;
static int d;
};
// 定義
const int test::a;
int test::c = 0xCC;
// 定義しない
// const int test::b;
// int test::d = 0xDD;
int main() {
// your code goes here
cout << hex;
// 宣言も定義もされているので、どちらもOK
cout << "static const int &a : 0x" << (int)(&test::a) << endl;
cout << "static const int a : 0x" << (int)(test::a) << endl << endl;
// 定義がないため、実体の必要な操作はエラー
// cout << "static const int &b : 0x" << (int)(&test::b) << endl;
// でも名前は定数のエイリアスとして使用可能
cout << "static const int b : 0x" << (int)(test::b) << endl << endl;
// 宣言も定義もされているので、どちらもOK
cout << "static int &c : 0x" << (int)(&test::c) << endl;
cout << "static int c : 0x" << (int)(test::c) << endl << endl;
// 定義がないため、実体の必要な操作はエラー
// cout << "static int &d : 0x" << (int)(&test::d) << endl;
// 値の参照に実体が必要なのでエラー
// cout << "static int d : 0x" << (int)(test::d) << endl << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IHRlc3QgewoKCS8vIOWuo+iogAoJc3RhdGljIGNvbnN0IGludCBhID0gMHhBQTsKCXN0YXRpYyBjb25zdCBpbnQgYiA9IDB4QkI7CgoJc3RhdGljIGludCBjOwoJc3RhdGljIGludCBkOwoKfTsKCi8vIOWumue+qQpjb25zdCBpbnQgdGVzdDo6YTsKCmludCB0ZXN0OjpjID0gMHhDQzsKCi8vIOWumue+qeOBl+OBquOBhAovLyBjb25zdCBpbnQgdGVzdDo6YjsKLy8gaW50IHRlc3Q6OmQgPSAweEREOwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgljb3V0IDw8IGhleDsKCQoJLy8g5a6j6KiA44KC5a6a576p44KC44GV44KM44Gm44GE44KL44Gu44Gn44CB44Gp44Gh44KJ44KCT0sKCWNvdXQgPDwgInN0YXRpYyBjb25zdCBpbnQgJmEgOiAweCIgPD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