[問題] g++
剛剛發現相同的code用不同版本的g++ compile好像會有不一樣的結果耶...
以下是用 Ubuntu 10.04 g++ 4.4.3 顯示的錯誤訊息
In file included from adtTest.h:53,
from adtTest.cpp:10:
../../include/bst.h: In constructor ‘
BSTree<T>::iterator::iterator(BSTreeNode<T>*, std::stack<BSTreeNode<T>*,
std::deque<BSTreeNode<T>*, std::allocator<BSTreeNode<T>*> > >, bool) [with T
= AdtTestObj]’:
../../include/bst.h:105: instantiated from ‘BSTree<AdtTestObj>::iterator’
adtTest.h:90: instantiated from here
../../include/bst.h:105: error: default argument for parameter of type ‘
std::stack<BSTreeNode<AdtTestObj>*, std::deque<BSTreeNode<AdtTestObj>*,
std::allocator<BSTreeNode<AdtTestObj>*> > >’ has type ‘int’
make[1]: *** [adtTest.o] Error 1
make: *** [main] Error 2
用 Ubuntu 11.10 g++ 4.6.1 則是順利通過...
而不通過的原因似乎是iterator的constructor的問題
在我的code是寫
iterator(BSTreeNode<T>* n=0, stack< BSTreeNode<T>* > t=0,......){...}
雖然當下覺得stack不知道能不能這樣亂設初值
不過反正compile能過就也沒想那麼多了
沒想到現在都寫完了才在不同版本的compiler上出了問題
不知道這該如何解決呢?
如果同一份code老師不能compile我是不是就gg了?? @@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.243.229
→
12/01 23:52, , 1F
12/01 23:52, 1F
→
12/01 23:58, , 2F
12/01 23:58, 2F
推
12/02 00:35, , 3F
12/02 00:35, 3F
→
12/02 00:36, , 4F
12/02 00:36, 4F
→
12/02 00:46, , 5F
12/02 00:46, 5F
推
12/02 09:17, , 6F
12/02 09:17, 6F
→
12/03 00:58, , 7F
12/03 00:58, 7F
討論串 (同標題文章)