我們可以訪問一個文件中定義的靜態函數到另一個文件嗎? 在下面的代碼中,我不能調用靜態方法fun()
。爲什麼我不能和有另一種方式來訪問它?我們可以將一個文件中定義的靜態函數訪問到另一個文件嗎?
static void fun();// In abc.h
static void fun(){cout<<"Hello."<<endl;}
//xyz.cpp
#include "abc.h"
void main()
{
fun();// Why I am not able to call this static method? Is there any other way to
//Access this static function?
}
這是功課嗎? – 2012-02-11 13:43:04
你正在給函數內部聯繫,然後想知道爲什麼你不能在外部調用它?這是一個真正的問題嗎? – ildjarn 2012-02-11 13:44:20
你的'fun()'_defined_在頭文件中嗎? – Lol4t0 2012-02-11 13:44:53