c++错误综合介绍

上传人:第*** 文档编号:49186063 上传时间:2018-07-25 格式:PPT 页数:33 大小:149KB
返回 下载 相关 举报
c++错误综合介绍_第1页
第1页 / 共33页
c++错误综合介绍_第2页
第2页 / 共33页
c++错误综合介绍_第3页
第3页 / 共33页
c++错误综合介绍_第4页
第4页 / 共33页
c++错误综合介绍_第5页
第5页 / 共33页
点击查看更多>>
资源描述

《c++错误综合介绍》由会员分享,可在线阅读,更多相关《c++错误综合介绍(33页珍藏版)》请在金锄头文库上搜索。

1、C+错误综合介绍掌握自己找错改错的方法class CForm private: char title40; int width; int height;public: CForm() strcpy(title,“Form1“); widht = 400; height = 350; 1.使用未经定义过的标识符的错误-Configuration: 错误综合练习 - Win32 Debug- - Compiling. Demo.cpp e:课件c+09c+错误综合练习form.h(11) : error C2065: strcpy : undeclared identifier e:课件c+09c

2、+错误综合练习form.h(12) : error C2065: widht : undeclared identifier 执行 cl.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)Compiling 编译 Error 错误 Warning 警告 Underclared 没有定义/声明 Identifier 标识符错误认识 这是一个在编译期间发现的语法性错误, 错误报告了中出现了两个错误点,它们的 内容都是: undeclared identifier “没有定义过的标识符”错误认识 这是一个在编译期间发现的语法性错误, 错误报告了中出现了两个错误

3、点,它们的 内容都是: undeclared identifier “没有定义过的标识符”改错提示 在程序中找到错误的位置和错误的标识符 ,看该标识符有没有被定义过。如果有, 则一般是因为同学标识符的使用名与定义 时的名称不一致,要特别注意大小写#include #include class CForm private: char title40; int width; int height;public: CForm() strcpy(title,“Form1“) width = 400; height = 350; 2.语句没有使用; 结束的错误-Configuration: 错误综合练习

4、 - Win32 Debug- Compiling. Demo.cpp e:课件c+09c+错误综合练习form.h(14) : error C2146: syntax error : missing ; before identifier width 执行 cl.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)syntax 句法 missing 缺少,丢失错误认识错误认识 这是一个在编译期间发现的语句错误,错 误报告了中出现了1个错误点,它们的内容 是: syntax error : missing ; before identifier width

5、 “在标识符widht前面缺少;”改错提示 在程序中找到错误的位置,一般错误并不 是在这个位置所在的行,而是在该行前面 一行的末尾处缺少;#include #include class CForm private: char title40; int width; int height;public: CForm() strcpy(title,”Form1”); width = 400; height = 350; 3.非法(无法理解的)字符错误-Configuration: 错误综合练习 - Win32 Debug- - Compiling. Demo.cpp e:课件c+09c+错误综合练

6、习form.h(13) : error C2018: unknown character 0xa1 e:课件c+09c+错误综合练习form.h(13) : error C2018: unknown character 0xb1 e:课件c+09c+错误综合练习form.h(13) : error C2018: unknown character 0xa3 e:课件c+09c+错误综合练习form.h(13) : error C2018: unknown character 0xbb 执行 cl.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)unkn

7、own 无法知道的、看不懂的 character 字符错误认识错误认识 这是一个在编译期间发现的错误,错误内容 是: error C2018: unknown character 0xa1 “无法理解的字符0xa1” 错误提示在程序当前位置有非法的字符,比如:中文字符 对于程序来说就属于非法字符 改错提示 在程序中找到错误的位置,把中文的字符 改为英文字符,特别要主要中文的“”和;的 误写或缺失。#include #include class CForm private: char title40; int width; int height;public: CForm() strcpy(ti

8、tle,“Form1“); width = 400; height = 350;4.没有结束块的语法错误-Configuration: 错误综合练习 - Win32 Debug- - Compiling. Demo.cpp E:课件c+09c+错误综合练习Demo.cpp(7) : fatal error C1004: unexpected end of file found 执行 cl.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)fatal 致命的 unexpected 未终止的 end of file 文件的末尾 Found 发现错误认识错误认

9、识 这是一个在编译期间发现的致命错误,错误 内容是: fatal error C1004: unexpected end of file found “在文件末尾发现为终止的意外” 通常是 不成对,特别是没有结束 改错提示 这个错误的位置很难判断,需要程序员耐 心仔细的一个一个块对进行查找。因此, 如果保持比较良好的程序编写习惯是找出 这一问题的捷径。#include #include “Form.h“void mian()5.没有main()的链接时错误或者根本没有-Configuration: 错误综合练习 - Win32 Debug- Compiling. Demo.cpp Linkin

10、g. LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/错误综合练习.exe : fatal error LNK1120: 1 unresolved externals 执行 link.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s) 这个问题的英语翻译不够准确,因此,学员们可以记住这个 symbol_main的单词组合,它只有一种错误的可能 Linking 链接 symbol_main main符号错误认识错误认识 这是一个在编译过后的链接过程中发现

11、的错 误,错误内容是:unresolved external symbol _main Debug/错误综合练习.exe :fatal error LNK1120: 1 unresolved externals “在链接的XXX.exe文件中出现的关于main符 号的未确定的外部错误” 通常是main()的单词写错了,或根本没有改错提示 只要看看main有没有写对就可以了,注意 main是函数,要写成: main() 6.拥有超过一个以上main()的错误-Configuration: 错误综合练习 - Win32 Debug- Compiling. Demo.cpp Linking. Dem

12、o2.obj : error LNK2005: _main already defined in Demo.obj Debug/错误综合练习.exe : fatal error LNK1169: one or more multiply defined symbols found 执行 link.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)already 已经 defined 被定义过 multiply 多次错误认识错误认识 这是一个在编译过后的链接过程中发现的错 误,错误内容是: Demo2.obj : error LNK2005: _main

13、already defined in Demo.obj Debug/ 错误综合练习.exe : fatal error LNK1169: one or more multiply defined “_main已经在Demo.obj中被定义过了,链接 的时候出现了超过一个以上的定义” 通常是一个工程中出现了多个main()改错提示 只保留一个main()#include #include “Form.h“void main() CForm form1; form1.SetTitle(); form1.SetSize(500); 7.调用函数时出现的错误请对着类中成员函 数定义时的参数类 型和个数

14、-Configuration: 错误综合练习 - Win32 Debug- Compiling. Demo.cpp E:课件c+09c+错误综合练习Demo.cpp(7) : error C2039: SetTile : is not a member of CForme:课件c+09c+错误综合练习form.h(4) : see declaration of CForm E:课件c+09c+错误综合练习Demo.cpp(8) : error C2660: SetSize : function does not take 1 parameters 执行 cl.exe 时出错.错误综合练习.exe - 1 error(s), 0 warning(s)member 成员,一般指成员属性或成员函数 declaration 定义,一般指类或函数的结构定义 function 函数 parameters 参数错误认识错误认识E:课件c+09c+错误综合练习Demo.cpp(7) : error C2039: SetTile : is not a member of CForme:课件c+09c+错误综合练习form.h(4) : see declaration of CForm E:课件c+09c+错误综合练习Demo.c

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 职业教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号