ConsoleApplication4.exe已停止工作.Windows将关闭该程序并通知是否有可用的解决方案
ConsoleApplication4.exe has stopped working. Windows will close the program and notify if a solution is available
我是c++和Visual Studio的新手。我试图在Visual Studio 2012中运行和调试代码。但是当代码需要一些更复杂的计算时,VS就像下面的例子一样崩溃了。编译后,当我点击开始没有调试,我得到一个弹出窗口显示上述消息。最后显示调试和关闭程序两个选项。当我点击调试时,它说"控制台application4.exe[5844]中发生了未处理的win32异常"。我不明白这是怎么回事。当我尝试运行一些简单的程序,如std::cout << "something";
,它显示正确的消息。
// ConsoleApplication4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "tbb/blocked_range.h"
#include "tbb/tbb.h"
#include <stdio.h>
#include <math.h>
#include <iostream>
#include "tbb/parallel_for.h"
using namespace tbb;
#define PI 3.14159265
class CL
{
double * rangeOne;
double * rangeTwo;
public:
CL(double * rangeOne, double * rangeTwo) {}
void operator()(blocked_range<size_t>& r)
const
{
for (size_t i = r.begin(); i != r.end(); ++i)
{
rangeOne[i] = sin(i*PI / 180);
rangeTwo[i] = cos(i*PI / 180);
}
}
};
int _tmain(int argc, _TCHAR* argv[])
{
double * u = new double[10];
double * p = new double[10];
parallel_for(blocked_range<size_t>(0, 10), CL(u, p));
return 0;
}
This:
CL(double * rangeOne, double * rangeTwo) {}
不初始化你的类变量。它什么也不做。什么也没有。
应该是:
CL(double * rangeOne, double * rangeTwo) : rangeOne(rangeOne), rangeTwo(rangeTwo) {}
但是请帮自己一个大忙,利用这个错误来学习如何使用调试器。这不会是你一生中遇到的最后一个错误。
通过F10一步一步地找出异常点,并检查出哪一步异常即将到来
相关文章:
- 在提升multi_index容器中,是否定义了"default index"?
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 检查输入是否不是整数或数字
- 是否可以初始化不可复制类型的成员变量(或基类)
- 是否有必要获取锁并在不需要唤醒线程时通知condition_variable?
- 当光标位置在编辑控件 MFC 中更改时是否有通知代码?
- 是否有任何常规方法可以通知 STL 移动和复制构造函数?
- 当在其他地方使用相同的互斥锁时,等待/通知unique_lock互斥锁是否安全lock_guard
- 通知线程是否始终需要在修改期间锁定共享数据
- Win32 中是否有一条消息或通知来检测用户何时更改区域设置?
- 当屏幕保护程序在Linux下启动或停止时,是否可以通知通知
- 阻塞模式下的WSASend()是否会导致在完成端口中放置通知数据包
- 在 Linux 的 C/C++ 中是否可以在达到指定的日期/时间时收到通知
- ZeroMQ是否有数据到达时的通知/回调事件/消息
- 是否可以编写一个windows应用程序,当在另一个窗口应用程序中选择文本时,该应用程序会收到通知
- 调试器分离时是否可以通知应用程序
- 是否可以连接到QApplication通知信号
- 从通知器到服务员的互斥锁传递是否无缝?
- 在Windows中,是否有办法在新的MIDI端口可用时获得通知?
- ConsoleApplication4.exe已停止工作.Windows将关闭该程序并通知是否有可用的解决方案