我知道這方面有很多問題,但是我檢查了我的程序中常見的錯誤,而且我似乎找不到任何錯誤。另一個「ISO C++禁止聲明」錯誤
我得到這些錯誤對我的拷貝構造函數在一個文件strlist.cpp的第一行:
ISO C++禁止的「Strlist」聲明沒有類型[-fpermissive] 沒有「廉政StrList: :Strlist(常量StrList &)」類的成員函數聲明爲 'StrList'
下面是部分:
/* copy constructor */
40 StrList::Strlist(const StrList& rhs)
41 {
42 intitList(&list);
43 Struct Node *current = (rhs.list).head;
44 while(current != NULL){
45 AddFront(*(const MyString *)current->data);
46 current = current->next;
47 }
48 reverse();
49 }
這裏是我的頭文件拷貝構造函數:
5 #ifndef __STRLIST_H__
6 #define __STRLIST_H__
11
12 #include "mystring.h"
13 #include "stdio.h"
14 #include "stdlib.h"
20
21 extern "C" {
22 #include "mylist.h"
23 }
24
25 class StrList {
26
27 public:
(......................)
40
41 /*copy constructor */
42 StrList(const StrList& rhs);
(..................)
105 };
106
107 #endif
我在strlist.cpp中包含了strlist.h,所以我無法弄清楚這有什麼問題。
謝謝!
C++是區分大小寫的。您還使用[保留標識符](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier)。 – chris
'struct node * current =(rhs.list).head;'你確定'Struct'應該大寫? – Brandon
即使是小寫字母,它也沒有任何用處。 – chris