導航:首頁 > 源碼編譯 > 類成員函數編譯中有哪些錯誤

類成員函數編譯中有哪些錯誤

發布時間:2024-05-10 12:39:50

⑴ 關於C語言在編譯時常出現的錯誤有哪些

1、fatal error C1010: unexpected end of file while looking for precompiled header directive。

尋找預編譯頭文件路徑時遇到了不該遇到的文件尾。(一般是沒有#include "stdafx.h")

2、fatal error C1083: Cannot open include file: 'R…….h': No such file or directory

不能打開包含文件「R…….h」:沒有這樣的文件或目錄。

3、error C2011: 'C……': 'class' type redefinition

類「C……」重定義。

4、error C2018: unknown character '0xa3'

不認識的字元'0xa3'。(一般是漢字或中文標點符號)

5、error C2057: expected constant expression

希望是常量表達式。(一般出現在switch語句的case分支中)

6、error C2065: 'IDD_MYDIALOG' : undeclared identifier

「IDD_MYDIALOG」:未聲明過的標識符。

7、error C2082: redefinition of formal parameter 'bReset'

函數參數「bReset」在函數體中重定義。

8、error C2143: syntax error: missing ':' before '{'

句法錯誤:「{」前缺少「;」。

9、error C2146: syntax error : missing ';' before identifier 'dc'

句法錯誤:在「dc」前丟了「;」。

10、error C2196: case value '69' already used

值69已經用過。(一般出現在switch語句的case分支中)

11、error C2509: 'OnTimer' : member function not declared in 'CHelloView'

成員函數「OnTimer」沒有在「CHelloView」中聲明。

12、error C2511: 'reset': overloaded member function 'void (int)' not found in 'B'

重載的函數「void reset(int)」在類「B」中找不到。

13、error C2555: 'B::f1': overriding virtual function differs from 'A::f1' only by return type or calling convention

類B對類A中同名函數f1的重載僅根據返回值或調用約定上的區別。

14、error C2660: 'SetTimer' : function does not take 2 parameters

「SetTimer」函數不傳遞2個參數。

15、warning C4035: 'f……': no return value

「f……」的return語句沒有返回值。

16、warning C4553: '= =' : operator has no effect; did you intend '='?

沒有效果的運算符「= =」;是否改為「=」?

17、warning C4700: local variable 'bReset' used without having been initialized

局部變數「bReset」沒有初始化就使用。

18、error C4716: 'CMyApp::InitInstance' : must return a value

「CMyApp::InitInstance」函數必須返回一個值。

19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing

連接錯誤:不能打開P1.exe文件,以改寫內容。(一般是P1.Exe還在運行,未關閉)

20、error LNK2001: unresolved external symbol "public: virtual _ _thiscall C……::~C……(void)"

連接時發現沒有實現的外部符號(變數、函數等)。

function call missing argument list 調用函數的時候沒有給參數。

member function definition looks like a ctor, but name does not match enclosing class 成員函數聲明了但沒有使用

unexpected end of file while looking for precompiled header directive 在尋找預編譯頭文件時文件意外結束,編譯不正常終止可能造成這種情況

⑵ c++類成員函數在類外定義,編譯錯誤!!!!!(3個文件)

你的分離編譯錯誤,主要是因為你在main中include linkqueue.h,而link queue的實現放在了cpp中導致。這里你的main include的linkqueeu.cpp,所以不會導致問題。


模板的實現一般都需要放在頭文件中,因為模板類似宏,編譯器需要根據提供的模板參數生成代碼,而如果編譯器看到模板的實現,那麼就生成不了代碼,最後鏈接會出錯。放在cpp里一般是你需要顯式實例化模板,並且不想讓用戶隨意對模板進行實例化,也就是用戶只能使用你提供的特化。

//foo.h
template<typenameT>
structfoo{
voidf();
};

//foo.cpp
#include"foo.h"
template<typenameT>
voidfoo<T>::f(){...}
//
templateclassfoo<int>;//只允許用戶使用int參數


一般不去includecpp文件,當然也不是完全不可以,因為只是一個文件而已。
你將linkqueue.cpp改成linkqueue.hpp或者linkqueue_impl.h等頭文件命名,之後在linkqueue.h中include這個頭文件,在main.cpp中只需要includelinkqueue.h即可。


頭文件一般需要用#ifndef #endif包裹起來,否在可能會出現被多次include的問題,導致編譯錯誤。

#ifndeffile_h
#definefile_h
//類定義,函數聲明等
#endif
閱讀全文

與類成員函數編譯中有哪些錯誤相關的資料

熱點內容
腰椎壓縮性骨折吧 瀏覽:324
安卓怎麼把軟體改成火影忍者 瀏覽:702
手機如何切換軟體商店伺服器 瀏覽:325
江蘇省python二級題型 瀏覽:231
文件編譯器在哪 瀏覽:26
選擇目錄時此電腦的文件夾怎麼刪 瀏覽:25
狗狗幣加密支付服務 瀏覽:897
怎麼使用指南針APP確定方向 瀏覽:372
php讀取圖片並輸出 瀏覽:321
如何組合多個pdf文件 瀏覽:669
工作表格excel取消加密 瀏覽:133
真空壓縮袋手泵怎麼用 瀏覽:426
鏡面的命令 瀏覽:203
51單片機藍牙模塊有延遲 瀏覽:115
b解壓葯 瀏覽:569
跳空缺口指標源碼怎麼寫 瀏覽:701
怎麼殺掉伺服器上所有進程 瀏覽:180
c語言中水仙花數的演算法分析 瀏覽:495
心煩時玩兒的解壓神器 瀏覽:497
linux安裝的庫文件 瀏覽:920