作者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