class SimpleVariant
{
public:
SimpleVariant() { /*...*/ };
// ...
};
struct VariantBlock
{
int nRows, nCols;
vector<SimpleVariant> theData;
};
void dumbFunction( VariantBlock& theBlock, int nRows, int nCols )
{
// ...
cout << "theBlock.nRows= " << theBlock.nRows
<< ", theBlock.nCols= " << theBlock.nCols
<< ", theBlock.theData.size() " << theBlock.theData.size();
theBlock.theData.resize( nRows * nCols );
// throws Access Violation Exception
// ...
}
出力は、nRows = 61、nCols = 5、size()= 0を返します。これは、アクセス違反例外がスローされる前のその時点での正確な値です。
私はMSVC6を使用していますが、これは明らかに最適ではありませんが、現時点では選択の余地はありません。