try-catch语句中的C ++崩溃

时间:2016-05-19 07:18:48

标签: c++ class testing crash try-catch

所以,我做了一个我们必须测试课程的作业。我们被禁止使用stl。:)问题是在test_2程序崩溃了。它一直有效,直到它得到主要的try语句。当它应该跳转到异常时它就会崩溃。知道为什么会这样吗?提前致谢! :)

p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px; /*width as you want */
}

1 个答案:

答案 0 :(得分:0)

已解决

我做了一个大小为40的obj并加载了400 int。这个过程使得test2对象720的大小(因为重载它的大小翻了一倍)所以我做了两个不同大小的对象相等。

Buffer<int> test2(40,"test2.txt","w");
        // first buffer

   cout << "bufferek made\n";

    for(unsigned int j=0;j<400;j++){
        test2[j]=tomb[j];            //load buffer

    }

    Buffer<int> test21(test2.getSize(),"test21.txt","w");   //make the second buffer