C++相談室 part83
■ このスレッドは過去ログ倉庫に格納されています
0051デフォルトの名無しさん
2010/08/14(土) 22:05:41以下のコードを実行させると。。。
enum index {
first,
second,
third,
end_of_index
};
index & operator +=( index & dst, const index & src ) {
reinterpret_cast< int & >( dst ) += src;
assert( ( first <= dst ) && ( dst < end_of_index ) );
return ( dst );
}
index operator +( const index & left, const index & right ) {
return ( index( left ) += right );
}
int main( int argc, char * argv[] )
{
index a, b = first, c = second;
a = b + c;
}
b の中身も変わってしまうのは何故なんだぜ?
■ このスレッドは過去ログ倉庫に格納されています