记录每次调试的错误
来源:互联网 发布:qq国际网络加速器 编辑:程序博客网 时间:2024/04/27 21:27
1.................................class Part{public :Part();~Part();private :int val;}clas whole{public : Part (); whole (); whole (int i,int y); private : Part one; Part two ; int hdate; }whole ::whole(int i,int y,int k):two(i),one(j),hdate(k)//two(i),one(j),逗号前的初始化内部成员对象的成员。 hdate(k)初始化自己成员 {}2.................................class B;//这样要声明 class A{public : void f(B b);};class B{public :public g(A a)};3.................................//模板//template <模板参数> template <class T>class complex{private :T real;T imagpublic :realcomplex();};template <class T>T complex<T>::realcomplex()// T (返回值) complex<T>::realcomplex(){return real;}int main(){complex<int> s1,s2;//使用模板定义参数int两个对象 complex<double> s1,s2;//使用模板定义参数double两个对象 }4.................................class A{public :static void f( A a);private :int x;} ;void A::f(A a){cout<<x;//错误 因为fun是静态成员 cout <<a.x;//对的 }5.................................class B{public :public : int g(int b)const;//常成员函数不能更新对象的数据成员 //一般常对象只能调用常成员函数,其他不能调用 };#include <iostream.h>class A{public :A(int i);void print();const int & r;private :const int a;static const int b;}const int A::b=10;A::A(int i):a(i),r(a){}//const 成员a必须这样赋值 void A::print(){}6.................................#include <iostream.h>int fun ();int main(){int a=fun();return 0;} int fun (){int *p=new int (5);return *p;}//上面写的内存没释放改成返回*p指向的内存就行了 #include <iostream.h>int fun ();int main(){int* a=fun();delete a;return 0;} int* fun (){int *p=new int (5);return *p;}基类指针可以执行派生类class A{} class B:public A{int yu(){}} int main(){A *p;B b;p=&b;p->yu();}
一.段错误:
原因:1.每个函数没赋值 2.函数赋错值。
解决方法:用打印跟踪,检查函数的参数
printf("xxxx \n");如果不加\n有时候会不输出
二。个函数调用出错
1.首先查看这个函数实现的文件
2.再看这个函数的文件的头文件有没有申明这个函数
3.看函数的返回和参数类型是否相同
三.malloc出错
ptNew = malloc(sizeof(T_VideoMem));
ptNew = malloc(sizeof(PT_VideoMem)); (错误)
ptNew = malloc(sizeof(PT_VideoMem)); (错误)
分配PT_VideoMem(是结构体指针)这个就会出现下面错误
show_file: malloc.c:3074: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
四。指针改变
pcTmp = strrchr(g_strCurDir, '/'); /* 找到最后一个'/', 把它去掉 */
*pcTmp = '\0';
这样也把g_strCurDir同时改了
五。c++学习笔记
for(int u=0;u<8;u++){if(a>u)continue;(条件成立,continue相当break)else{printf("u=%d\n",u);}printf("u=%d\n",u);}
只有当a>u不成立下面语句才执行,不成立下面语句else分支执行,下面的也执行,否则直接跳出下面不执行
以后会加入更多。
- 记录每次调试的错误
- 调试错误记录
- 错误调试记录2
- 程序调试错误记录
- 每次记录一点Idea的使用心得
- hbase错误调试过程记录
- 调试Opal 3.12.8中出现的错误记录
- 调试中遇见的错误记录--逐步增加
- MySQL存储函数错误[Err] 1064的调试记录
- MySQL存储函数错误[Err] 1064的调试记录
- 生成活动码,每次获取的记录不重复
- 批处理怎样记录每次运行所需的时间
- mysql 存储过程错误调试记录
- windows下调试软件错误记录
- Ubuntu14.04 运行程序错误,调试记录
- c++中几个段错误调试记录
- CATVehicle 调试过程中错误记录
- Ubuntu每次打开终端出现错误提示的解决方法
- java中设计模式
- linux编程文件描述符传递
- Socket原理与编程基础
- Linux下线程池的设计
- OpenCV笔记11:霍夫变换检测直线
- 记录每次调试的错误
- Python线程指南
- poj3468——A Simple Problem with Integers(线段树)
- OpenCV笔记12:霍夫变换检测圆
- 汇编语言学习笔记--第一个汇编程序
- 【转】Java工具类——数字计算工具 NumberUtil
- OpenCV笔记13:Seq读写操作
- poj1679(The Unique MST)Kruskal
- How to find the HTML5 feature for your HTML5R