ios::binaryの実装について調べてみた。
ソースみりゃ一発ですが、なんか気になったので調べてみた。
// TemplateSample01.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> class SpriteBlend { private: SpriteBlend() { } public: enum _blend_type { }; static const _blend_type Normal = (_blend_type)0x0; static const _blend_type Add = (_blend_type)0x1; static const _blend_type Sub = (_blend_type)0x2; }; typedef int sprite_blend; class Sprite { private: sprite_blend blend_; public: Sprite(){ } void SetBlend( sprite_blend blend ) { blend_ = blend; } sprite_blend GetBlend( void ) { return blend_; } }; using namespace std; int _tmain(int argc, _TCHAR* argv[]) { Sprite spr; spr.SetBlend( SpriteBlend::Add ); cout << spr.GetBlend() << endl; return 0; }
class内にenumを宣言し、その名前でconst定数を宣言。
あと、int型をtypedefで別名に。
SpriteBlendは、オブジェクト作れないようにしておく。
ios::binary | ios::load
等ができるのは、open_modeがint型だったからなのね。。。