C/C++小心者スレッドPart1
■ このスレッドは過去ログ倉庫に格納されています
0056デフォルトの名無しさん
2008/08/05(火) 15:26:30例としては無効な引数、〜が見つからない、致命的なエラーなどです。
クラス毎に static const 〜 としてもいいのですが、同じ値に保つのが面倒になりそうだし、、、
専用のクラスを作り下記のようにしようかと考えたのですが、スマートではない気がしています。
皆さんはどうされていますか? よろしくお願いします。
class CResultCode {
static const int s_success = 1;
static const int s_falal_error = -1;
static const int s_invalid_param = -2;
static const int s_file_not_found = -10;
static bool IsSuccessful(int in_result) { return in_result > 0; };
};
class CHoge {
int Hoge(){ return CResultCode::s_successed; };
};
void main() {
CHoge hoge;
int res = hoge->Hoge();
if ( !CResultCode::IsSuccessful(res)){
エラー処理
}
}
■ このスレッドは過去ログ倉庫に格納されています