作者sa901119 (ads901119)
看板EE_DSnP
標題Re: [問題] 不能將函式 static bool ModNum::setVa …
時間Sat Apr 11 22:45:39 2009
: 1.
: 在 calcModNum.h 裡面有好幾個 static bool 函數
: 我在 calcModNum.cpp 裡面寫上
: static bool ModNum:: getStrVal(...){....}
: 這種東西就會被回報錯誤
: 叫做 "不能將成員函式 static bool ModNum:: ..... " 宣告為有靜態連結
: 不知道是甚麼意思
When implementing functions in .cpp files, "static" must not be written.
i.e.
class ModNum
{
...
static bool ModNum::getStrVal(...){...}
...
};
//outside class definition
bool ModNum::getStrVal(...){...} //don't write "static" explicitly.
: 2.
: 請問一下我要寫 testMC 檔只要切換到在 test 資料夾底下打 make test 就好了嗎?
yes, or "make ./test"
: 還是要撰寫 makefile...?
: 3.
: 要怎麼引用 myString.cpp 裡面的函數呀?
: 以前只聽過有人include .h 檔案
: 沒有寫過 include .cpp 檔
: 我看見了 util.h 檔裡面有加上 extern ...(myString 裡面的函數)
: 聽說這樣的寫法表示告訴電腦某函數寫在別的檔案裡
: 但是如果除此之外並沒有人講說那些函數在哪個檔案裡
: 還能夠找的到嗎?
You only need to include .h files.
Those linking problems are done by Makefile, so the computer knows the
implementation of classes.
: 4.
: 這次的作業檔案散落各地分佈在很多個資料夾裡
: 實際上要怎麼把他們合體變成一個執行檔呢?
Our considerate professor ric has written the Makefile for us, so just
"make" and the executable will be generated.
Hope my answers are right, if there's any error, please point out. Thx
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.252.248
1F:推 timrau:linking還是GCC負責的;Makefile只是告訴make怎樣呼叫指令 04/11 22:52
2F:推 FATCLOUD:感謝~ 已解決 04/11 23:31