visual studio 2015中建了一個c++的專案,有兩個cpp檔案,其中一個有main函式,另一個有一個一般的函式,為什么main函式呼叫另一個函式會出錯
test.cpp
#include <iostream>
using namespace std;
int main(){
test();
return 0;
}
test1.cpp
#include <iostream>
using namespace std;
void test(){
cout<<"aaaaaaaaa"<<endl;
}
運行的時候說會出現test:找不到識別符號
uj5u.com熱心網友回復:
test.cpp#include <iostream>
using namespace std;
extern void test(); //試試加入這句
int main(){
test();
return 0;
}
uj5u.com熱心網友回復:
可以運行了,謝謝uj5u.com熱心網友回復:
如果我寫了一個test1.h頭檔案,在test.cpp中包含了頭檔案也要加上這句嗎?uj5u.com熱心網友回復:
#include 一個頭檔案,你要理解展開以后就等于直接把頭檔案的內容寫在那個位置。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/77377.html
標籤:基礎類
上一篇:C語言取亂數,幾次之后就不隨機了
