作者simpdanny (辛普丹尼)
看板EE_DSnP
标题[问题] compiling adtTest.cpp...
时间Sat Nov 26 14:59:02 2011
============解答已出炉============
因为dlist.h最後少加一大括号
导致整个definition 错位
在adtTest.cpp就会有定义错误的问题...
=========解答完毕之我蠢了=========
compiling 是件刺激的事情
尤其是你不知道bug会从四面八方何处猛然冒出捅人
怎麽死的都不知道...
-
刚刚雀跃地想试试看compile
结果就出现一长串的错误:
compiling: adtTest.cpp
In file included from adtTest.cpp:10:0:
adtTest.h:75:65: warning: friend declaration ‘std::ostream&
operator<<(std::ostream&, const DList<T>::AdtTestObj&)’ declares a
non-template function
adtTest.h:75:65: note: (if this is not what you intended, make sure the
function template has already been declared and add <> after the function
name here)
adtTest.h:120:4: error: need ‘typename’ before ‘
DList<DList<T>::AdtTestObj>::iterator’ because ‘DList<DList<T>::AdtTestObj>
’ is a dependent scope
adtTest.h:154:52: error: ‘DList<DList::AdtTestObj>::iterator’ is not a type
adtTest.cpp:16:27: error: type ‘DList<T>::AdtTestObj’ is not derived from
type ‘DList<T>’
adtTest.cpp:35:24: error: cannot define member function ‘
DList<T>::AdtTestObj::AdtTestObj’ within ‘DList<T>’
adtTest.cpp:42:55: error: ‘std::ostream& DList<T>::operator<<(std::ostream&,
const DList<T>::AdtTestObj&)’ must take exactly one argument
adtTest.cpp:51:39: error: cannot define member function ‘
DList<T>::AdtResetCmd::exec’ within ‘DList<T>’
adtTest.cpp:65:33: error: cannot define member function ‘
DList<T>::AdtResetCmd::usage’ within ‘DList<T>’
adtTest.cpp:71:21: error: cannot define member function ‘
DList<T>::AdtResetCmd::help’ within ‘DList<T>’
adtTest.cpp:81:37: error: cannot define member function ‘
DList<T>::AdtAddCmd::exec’ within ‘DList<T>’
adtTest.cpp:110:31: error: cannot define member function ‘
DList<T>::AdtAddCmd::usage’ within ‘DList<T>’
adtTest.cpp:116:19: error: cannot define member function ‘
DList<T>::AdtAddCmd::help’ within ‘DList<T>’
adtTest.cpp:127:40: error: cannot define member function ‘
DList<T>::AdtDeleteCmd::exec’ within ‘DList<T>’
adtTest.cpp:175:34: error: cannot define member function ‘
DList<T>::AdtDeleteCmd::usage’ within ‘DList<T>’
adtTest.cpp:182:22: error: cannot define member function ‘
DList<T>::AdtDeleteCmd::help’ within ‘DList<T>’
adtTest.cpp:192:39: error: cannot define member function ‘
DList<T>::AdtPrintCmd::exec’ within ‘DList<T>’
adtTest.cpp:218:33: error: cannot define member function ‘
DList<T>::AdtPrintCmd::usage’ within ‘DList<T>’
adtTest.cpp:224:21: error: cannot define member function ‘
DList<T>::AdtPrintCmd::help’ within ‘DList<T>’
adtTest.cpp:227:1: error: expected ‘}’ at end of input
In file included from adtTest.cpp:10:0:
adtTest.h: In member function ‘void DList<T>::AdtTest::deleteRandom(size_t)’
:
adtTest.h:100:41: error: there are no arguments to ‘getPos’ that depend on
a template parameter, so a declaration of ‘getPos’ must be available
adtTest.h:100:41: note: (if you use ‘-fpermissive’, G++ will accept your
code, but allowing the use of an undeclared name is deprecated)
adtTest.h: In member function ‘void DList<T>::AdtTest::printForward()’:
adtTest.h:135:7: error: need ‘typename’ before ‘
DList<DList<T>::AdtTestObj>::iterator’ because ‘DList<DList<T>::AdtTestObj>
’ is a dependent scope
adtTest.h:135:37: error: expected ‘;’ before ‘li’
adtTest.h:136:14: error: ‘li’ was not declared in this scope
adtTest.h: In member function ‘void DList<T>::AdtTest::printBackward()’:
adtTest.h:143:7: error: need ‘typename’ before ‘
DList<DList<T>::AdtTestObj>::iterator’ because ‘DList<DList<T>::AdtTestObj>
’ is a dependent scope
adtTest.h:143:37: error: expected ‘;’ before ‘li’
adtTest.h:143:62: error: ‘li’ was not declared in this scope
adtTest.h: In member function ‘void DList<T>::AdtTest::printData(size_t,
int, size_t)’:
adtTest.h:156:36: error: invalid type argument of unary ‘*’
adtTest.cpp: At global scope:
adtTest.cpp:30:1: error: expected unqualified-id at end of input
-
虽然很挫志,
但是面临bug不de怎能说修过DSnP(?)
但就在此时我赫然发现...
...
adtTest.cpp我压根儿没动过啊...
...
哪呢!?
据说作业的所有问题都可以靠make clean->make 32解决
没变
据说我有可能在参考implementation时动到
重新解压缩!
没变...
连error message都给我难兄难弟般的一模一样
Q _ Q
这...
难道我在某个地方做了蠢事!?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.191
1F:→ shryuhuai:'DList<DList::AdtTestObj>::iterator’ is not a type 11/26 15:41
2F:→ shryuhuai:我猜是定义iterator的scope漏了}或; 11/26 15:44
3F:→ simpdanny:检查了...不是,这样如此应该是compile dlist.h错误吧? 11/26 16:01
4F:→ djshen:所以还没找到错喔@@ 11/26 16:04
5F:→ simpdanny:对啊... 11/26 16:04
6F:→ djshen:看起来的确像是哪里忘了加}.. 11/26 16:08
7F:→ shryuhuai:会不会是iteerator的scope结尾没有加; 11/26 16:12
8F:→ simpdanny:djshen(大钧神)是对的!=..=谢谢>"< 11/26 16:34
※ 编辑: simpdanny 来自: 140.112.4.191 (11/26 16:37)
9F:→ simpdanny:谢谢你们帮忙Q^Q 11/26 16:38
10F:→ djshen:.. 11/26 16:53