|
|
用c++编写了一个程序(在附件中,其中的EnhancedLinkedList.h自己编写,另两个一个是测试用,一个是已经提供的程序),然后用g++编译: g++ testdriver.cpp -o testdriver
出现错误如下:
spirit@freefly:~/EX/OE1/handout-files$ g++ testdriver.cpp -o testdriver
EnhancedLinkedList.h: In member function ‘T& EnhancedLinkedList<T>::find_first(const T&)’:
EnhancedLinkedList.h:13: 错误: ‘head’ 在此作用域中尚未声明
EnhancedLinkedList.h: In member function ‘EnhancedLinkedList<T> EnhancedLinkedList<T>::find_all(const T&)’:
EnhancedLinkedList.h:27: 错误: ‘head’ 在此作用域中尚未声明
EnhancedLinkedList.h: In member function ‘void EnhancedLinkedList<T>::remove_first(const T&)’:
EnhancedLinkedList.h:42: 错误: ‘head’ 在此作用域中尚未声明
EnhancedLinkedList.h:52: 错误: there are no arguments to ‘pop_front’ that depend on a template parameter, so a declaration of ‘pop_front’ must be available
EnhancedLinkedList.h:52: 错误: (如果您使用 ‘-fpermissive’,G++ 会接受您的代码,但是允许使用未定义的名称是过时的风格)
EnhancedLinkedList.h:53: 错误: no post-decrement operator for type
EnhancedLinkedList.h:60: 错误: no post-decrement operator for type
EnhancedLinkedList.h:63: 错误: ‘tail’ 在此作用域中尚未声明
EnhancedLinkedList.h:64: 错误: there are no arguments to ‘pop_back’ that depend on a template parameter, so a declaration of ‘pop_back’ must be available
EnhancedLinkedList.h:65: 错误: no post-decrement operator for type
EnhancedLinkedList.h: In member function ‘T& EnhancedLinkedList<T>::find_first(const T&) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
testdriver.cpp:25: instantiated from here
EnhancedLinkedList.h:17: 错误: 不能将 ‘search-> Node<T>::getData [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()’ 转换为 ‘bool’
EnhancedLinkedList.h: In member function ‘EnhancedLinkedList<T> EnhancedLinkedList<T>::find_all(const T&) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
testdriver.cpp:110: instantiated from here
EnhancedLinkedList.h:33: 错误: 不能将 ‘search-> Node<T>::getData [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()’ 转换为 ‘bool’
EnhancedLinkedList.h: In member function ‘void EnhancedLinkedList<T>::remove_first(const T&) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
testdriver.cpp:122: instantiated from here
EnhancedLinkedList.h:47: 错误: 不能将 ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ 转换为 ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >*’,在 assignment 中
EnhancedLinkedList.h:48: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
EnhancedLinkedList.h:49: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
EnhancedLinkedList.h:50: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
testdriver.cpp:122: instantiated from here
EnhancedLinkedList.h:56: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
EnhancedLinkedList.h:57: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
EnhancedLinkedList.h:58: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
EnhancedLinkedList.h:59: 错误: type ‘class Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ argument given to ‘delete’, expected pointer
testdriver.cpp:122: instantiated from here
EnhancedLinkedList.h:70: 错误: base operand of ‘->’ has non-pointer type ‘Node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’
希望大家查看一下附件,我认为是EnhancedLinkedList.h头文件没有将LinkedList.h头文件包含进去的原因,其中涉及了头文件的互相包括,希望大家帮忙看看,谢谢! |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|