随笔分类 -  C/C++ errors

1

C++ Arithmetic Exception
摘要:运算异常错误,比如除零错误,浮点数取余等等。 阅读全文

posted @ 2013-07-16 16:05 铁树银花 阅读(1304) 评论(0) 推荐(0)

Qt undefined reference to ***
摘要:错因:某个类声明了一个函数但是没有定义就直接使用。 阅读全文

posted @ 2013-06-18 19:57 铁树银花 阅读(418) 评论(0) 推荐(0)

error: '>>' should be '> >' within a nested template argument list|
摘要:错误现场:vector<pair<ll, int>> v;在“<<”中加一个空格即可:vector<pair<ll, int> > v; 阅读全文

posted @ 2013-03-10 17:06 铁树银花 阅读(4644) 评论(0) 推荐(0)

无法定位程序输入点_Z5qFreePv于动态链接库QtCore4.dll
摘要:在环境变量PATH中,把Qt的bin文件夹的目录的路径放到第一位,以防别的文件里面也有QtCore4.dlL,保证调用的是qt/bin中的dll文件 阅读全文

posted @ 2013-03-06 20:50 铁树银花 阅读(1007) 评论(0) 推荐(0)

运行Qt release版本时出现“丢失QtCore4.dll”错误
摘要:在Qt安装目录的bin文件夹中寻找QtCore4.dll文件,如果没找到,就到网上下载一个放入其中,否则就是环境变量没有设置好。把该文件所在目录的路径添加到环境变量中即可。 阅读全文

posted @ 2013-03-06 20:47 铁树银花 阅读(607) 评论(0) 推荐(0)

warning: name lookup of `i' changed
摘要:出错现场:int main(){ int i; for(int i = 0; i < 10; i++) ……}i 这个变量名重复使用 阅读全文

posted @ 2013-02-15 12:48 铁树银花 阅读(1460) 评论(0) 推荐(0)

error: expected unqualified-id before 'int'
摘要:出错现场: bool i, int j;将逗号改成分号即可。C/C++不能在同一条语句中定义不同类型的变量。 阅读全文

posted @ 2013-02-06 21:18 铁树银花 阅读(1138) 评论(0) 推荐(0)

vc6.0执行程序正确而debug版和release版运行错误
摘要:使用vc6.0直接执行程序和执行debug版本或release版本的程序在执行环境上有差异。vc6中调试运行时,默认的当前目录是工程.dsw文件所在的目录,而debug版或release版直接运行时,当前目录是exe所在的目录。比如有文件1.txt在dsw文件所在目录下而不在exe文件所在目录下,则用vc直接运行程序时能打开1.txt,但直接运行exe文件时打开失败。 阅读全文

posted @ 2013-01-08 20:49 铁树银花 阅读(252) 评论(0) 推荐(0)

convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
摘要:错误程序:#include <iostream> #include <vector> using namespace std; struct A { int x; A(int y) {x = y;} }; int main() { A a(11217); vector<A> V; V.push_back(a); vector<A>::iterator it = V.begin(); A *p = it; return 0; }编译报错:error: cannot convert 'std::vector<A>::iterat. 阅读全文

posted @ 2012-12-19 18:47 铁树银花 阅读(1817) 评论(0) 推荐(0)

error: creating array of references( declaration of 'a' as array)
摘要:错误程序:#include <iostream> using namespace std; void func(int& a[], int n) { for(int i = 0; i < n; i++) a[i]++; } int main() { int a[3] = {1, 2, 3}; func(a, 3); cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl; return 0; } 初衷:通过建立引用型形参 阅读全文

posted @ 2012-12-19 17:02 铁树银花 阅读(345) 评论(0) 推荐(0)

error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
摘要:string filename = "1.txt"; ifstream fin; fin.open(filename); 上述语句会产生如下错误:error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)原因是C++的string类无法作为open的参数。解决方案:使用C的字符串。例: char filename[10]; strcpy(filename, "1.txt"); ifstream fin; fin.o 阅读全文

posted @ 2012-12-15 23:23 铁树银花 阅读(5797) 评论(0) 推荐(0)

error: macro names must be identifiers
摘要:遇到的问题:工程中有一个头文件以数字为开头命名,编译结果显示预处理时出错,显示信息为error: macro names must be identifiers。中文大意应该“宏名称必须是标识符”。解决方案:将头文件重命名为字母开头,error消失。猜测:C++和C中命名变量时不能以数字开头,定义宏时也不能。 阅读全文

posted @ 2012-12-05 10:38 铁树银花 阅读(717) 评论(0) 推荐(0)

error LNK2001: unresolved external symbol _main
摘要:Win32 控制台应用程序需要 main 函数作为入口点。当链接器在附加到项目的任何文件中都找不到 main 函数时会返回此错误消息。加上main()函数即可 阅读全文

posted @ 2012-11-11 23:38 铁树银花 阅读(113) 评论(0) 推荐(0)

MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误
摘要:程序运行时弹出提示框原因:数组访问越界。 阅读全文

posted @ 2012-11-07 10:04 铁树银花 阅读(528) 评论(0) 推荐(0)

MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
摘要:运行程序时,弹出提示框出错的原因是,我删掉了一个编辑框,但是没有清除相应对话框类(***Dlg.h)和资源头文件(Resource.h)中的相关信息。我删除的编辑框的映射变量为“m_strOverflow”,在所有文件中查找这一关键词,注释掉相关语句,程序就能正常运行。 阅读全文

posted @ 2012-11-07 09:36 铁树银花 阅读(429) 评论(0) 推荐(0)

<errors>'MessageBoxA' : function does not take 1 parameter
摘要:'MessageBoxA' : does not take 1 parameters原因及解决方法 AfxMessageBox()一般应用于窗体之中,没有窗体,或者是全局函数,不能使用该函数;MessageBox()可以应用于没有窗体和有窗体的两种情况1)在有窗体的情况下,和AfxMessageBox()的用法一样,也就是只要一个参数;2) 在没有窗体或者全局函数中,他必须传入一个窗体句柄才可能执行,如果没有,用NULL代替也可,但是此时该消息框属于桌面,可能达不到我们所需要的目的,所以一般要传入一个窗口句柄。第二种情况下须给出函数的四个参数int MessageBox(HWN 阅读全文

posted @ 2012-10-20 13:23 铁树银花 阅读(376) 评论(0) 推荐(0)

模板实例化函数链接出错:error LNK2019: unresolved external symbol
摘要:模板类的定义和实现要放在一个文件中 阅读全文

posted @ 2012-10-15 00:05 铁树银花 阅读(213) 评论(0) 推荐(0)

'operator =' must be a <Unknown> member
摘要:赋值运算符“=”,不能以友元函数方式重载,只能重载为某类中的成员函数. 阅读全文

posted @ 2012-10-02 12:45 铁树银花 阅读(296) 评论(0) 推荐(0)

[置顶] 错误存档
摘要:1.当n是short int ,m是long long int时,语句m=4*n,使用GNU,得到的m是short int的范围,因此当n稍大时,m就可能溢出。2.输出字符串时,遇到‘\0’结束输入,如果没有适当地设置'\0',可能会出现问题。比如有struct node{ char s[10];}n[2];如果w[0].s中没有‘\0’,则scanf("%s",n[0].s)不会只输出n[0]中字符数组s中的内容,因为这一个输出语句是输出以n[0].s为首地址直到'\0'为止的内容。3.当用memset给char型以外的数组初始化时,只能初 阅读全文

posted @ 2012-07-18 11:50 铁树银花 阅读(204) 评论(0) 推荐(0)

error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_s
摘要:没有添加头文件,cout不能直接输出string类的变量。 阅读全文

posted @ 2012-06-08 08:02 铁树银花 阅读(3606) 评论(0) 推荐(0)

1

导航