以下C++程序編譯良好,但給出了運行時,下面的錯誤(Runtime check failure
):C++具體地解決了錯誤:變量「T」被使用而不被初始化
The variable 't' is being used without being initialized
#include <iostream>
#include<conio.h>
using namespace cv;
using namespace std;
void foo (int * count)
{
*count=90;
}
int main()
{
int *t;
foo(t);
cout<<t[0]<<endl;
return 0;
}
我會刪除這個錯誤在C中是這樣的:
int main()
{
int *t;
t= (int *) malloc(sizeof(int));
foo(t);
cout<<t[0]<<endl;
getch();
return 0;
}
這個錯誤的C++特定解決方案是什麼?
你想對「新」做些什麼研究。 – Aesthete
再次閱讀你的代碼,你發現一個版本有多一行?並再次閱讀錯誤消息,你明白嗎? –