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,这显然不是最佳选择,但此时别无选择。