看起來在C++ extern
(NOT後跟一個語言鏈接字符串文字)在名稱空間範圍(Difference between declaration of function with extern and without it)上的函數聲明沒有區別。但是它對塊範圍函數聲明有什麼影響嗎?或者是沒有extern
的本地函數聲明總是等於extern
?函數的本地/塊範圍聲明與沒有它的函數的區別
namespace {
void f() {
extern void g(); // has external linkage
g();
}
void f2() {
void g(); // always the same, as if, without extern
g();
}
}
謝謝!
爲什麼要在函數內聲明一個函數?你認爲它有什麼作用? –
與extern相反的是static - 'static void g(); //內部聯動「。 –
@underscore_d檢出http://stackoverflow.com/questions/1034606/is-there-any-use-for-local-function-declarations – EulersRainbow