算法与设计
调试错路的程序员
走过错误路的不谈前途的程序员
展开
-
基类析构作为虚函数
这样做是为了当用一个基类的指针删除一个派生类的对象时,派生类的析构函数会被调用扩展:多态 程序结构中的设计模式原创 2021-09-28 07:20:50 · 82 阅读 · 0 评论 -
软件的结构
包,执行过程,执行方式设计模式 界面库为什么使用友元函数 友元类第三方库的调用多态的使用代码与界面的 耦合原创 2021-09-25 09:07:04 · 78 阅读 · 0 评论 -
类的抽象能力
class:人员,学校,通道,告警抽象能力的重要性,std::list<person*> mylist;人员结构体。界面展示,duilib自绘控件之间的抽象。没有抽象能力就没有掌握面向对象编程。最牛的语言还是c/c++无论开源发展到多么牛,没有自己的抽象表达,越庞大的类库越是一堆废墟。高楼大厦建立在一堆废墟上,迟早是要吃苦头的。伟大的抽象能力,想象一下,一个牛逼的软件在你的抽象之下产生,而不是建立在别人的一堆烂库上。...原创 2021-09-09 21:58:20 · 64 阅读 · 0 评论 -
snprintf(仰看天色改)
// test11.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;#include <string.h>#define snprintf _snprintf#define REMAIN_SIZE(s) (sizeof(s)-strlen(s)) #define strcat_var(s, fmt, va.原创 2021-08-25 21:44:02 · 54 阅读 · 0 评论 -
i++为什么不能作为左值,而++i可以作为左值
// test11.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;#include <string.h> int _tmain(int argc, _TCHAR* argv[]) { int a = 4; a += (a++); cout<<a<<endl; i.原创 2021-08-25 20:22:53 · 387 阅读 · 0 评论 -
ioctl 和 strncmp
ioctl(缅思桃源内),网络的控制,ioctl就是应用层到驱动通信的桥梁,仿佛真实世界与陶公桃源之间。网络的世界何尝不是桃源世界,这就是伟大的现实主义诗词的意义,一个真实的世界一切纠隔杜甫真的用中文写绝了,万古无其一,把这个真实世界的概念加到理工世界,我觉得可以解决一切数学物理化学反应生命科学的逻辑记忆问题……一个真实世界的伟大复杂肯定超过虚拟世界……用杜诗学编程……我的创意……strncmp可以用个姊妹复何在?这种人的中文水平简直就是神……...原创 2021-08-18 22:23:48 · 53 阅读 · 0 评论 -
strdup(生还偶然遂)
#include <stdio.h>#include <assert.h> #include <stdlib.h>#include<string.h>int main(void){ char *src ="This is the strdup test"; char *dest; dest = strdup(src); printf("the dest %s\n",dest); free(dest).原创 2021-08-18 15:47:41 · 62 阅读 · 0 评论 -
sscanf(生涯定几回)
sscanf与scanf类似,都是用于输入的,只是后者以键盘(stdin)为输入源,前者以固定字符串为输入源原创 2021-08-18 15:23:15 · 47 阅读 · 0 评论 -
strtoul(往来时屡改)
#include <stdio.h>#include <assert.h>#define null NULLint comm_macstr_validitycheck(char* inMACstr18){ int i; int ret; char *p1, *p2; ret=strlen(inMACstr18); if(ret!=17) { //printf("strlen=%d\n", ret); .原创 2021-08-18 14:46:05 · 79 阅读 · 0 评论 -
fwrite(父老四五人)
fwrite((char*)buf,1,size,fp);原创 2021-08-18 11:54:03 · 119 阅读 · 0 评论 -
strreq截取最后一段:
#include <iostream>using namespace std;template <class T>inline void SAFEDELETE(T *&t) { T *tmp = t; t = NULL; delete tmp;} #include <string.h> class CXSUtil{public:static void strrep(const char *indata, char *.原创 2021-08-18 09:24:46 · 70 阅读 · 0 评论 -
c语言实现strcpy
#include <stdio.h>#include <assert.h>#define null NULL char * strcpy1(char* strdest,const char* strsrc){ assert((strdest!=null)&& (strsrc != null)); char *address = strdest; while((*strdest++ = *strsrc++)!='\0'); .原创 2021-08-16 15:53:10 · 61 阅读 · 0 评论 -
union 值多少
#include <stdio.h>int main(){ union{ int a; char b[4];} u; u.b[3]=1; printf("%d",u.a);}16809982u.b[0]=1;32513原创 2021-08-16 15:20:38 · 101 阅读 · 0 评论 -
virtual 输出ccbb
#include <iostream>using namespace std;class A{ public: virtual void f1() {printf("a");} void f2() { printf("b");}};class B:public A{ public: void f1() { printf("c");} void f2() {printf("d");}};int m.原创 2021-08-16 14:44:57 · 118 阅读 · 0 评论 -
指针的指针sizeof
int main(){int **abc; printf("%ld",sizeof(abc));}8原创 2021-08-16 14:34:59 · 70 阅读 · 0 评论 -
virtual多态
class A{ public: A() {f1();} void f() {f1();} void f1() { printf("a");}};class B:public A{ public: void test() { f();} virtual void f1() {printf("b");}};int main(){ B b; b.test(); return.原创 2021-08-16 14:23:12 · 64 阅读 · 0 评论 -
virtual 虚函数理解
#include <iostream>using namespace std;class A{ public: A() {f1();} void f() {f1();} virtual void f1() { printf("a");}};class B:public A{ public: void test() { f();} void f1() {printf("b");}};in.原创 2021-08-16 14:19:06 · 60 阅读 · 0 评论 -
位操作置位
#include <stdio.h> int setbit(int num,int n){ return num | (1<<(n-1)); } int clearbit(int num ,int n){ return num & ~(1 << (n-1)); }int main(){int i =2;int b = setbit(i,3);printf("%d",b);}6原创 2021-08-15 22:12:11 · 141 阅读 · 0 评论 -
测试题输出g
#include <string.h> int _tmain(int argc, _TCHAR* argv[]){ char a[]="progamming",b[]="language"; char *p1,*p2; int i; p1 = a; p2 = b; for(i=0;i<7;i++) if(*(p1+i) == *(p2+i)) printf("%c",*(p1+i)); system("PAUSE"); .原创 2021-08-15 16:39:10 · 76 阅读 · 0 评论 -
数组下标++错误
int _tmain(int argc, _TCHAR* argv[]){int a[6]={1,2,3,4,5,6};int *p = a;std::cout<<*(a+1)<<endl;std::cout<<*(p+1)<<endl;int *s;// s = a++;// s = ++a;s = p++;std::cout<<*s <<endl;system("PAUSE");re.原创 2021-08-15 16:17:06 · 202 阅读 · 0 评论 -
char*输出
#include <string.h>char* ss(char *s){ return s + strlen(s);}int _tmain(int argc, _TCHAR* argv[]){ char *p,str[]="huawei-3com"; p = ss(str); printf("%s\n",p); system("PAUSE"); return 0;}输出为空....原创 2021-08-15 16:04:26 · 910 阅读 · 0 评论 -
a为整型数组,&a+1的含义
/**把int a[10]变下形,为:int *(&a)[10],这样就可以直观的看出 来,&a就相当于指向一个int [10]类型的指针变量,于是&a到&a+1的变化 就是它指向的变量所占用的内存单元的大小4*10字节=40字节 **/int _tmain(int argc, _TCHAR* argv[]){ int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d\n",*(a+1),原创 2021-08-14 17:14:31 · 340 阅读 · 0 评论 -
宏定义括号重要
#define YEAR_SEC ((((1*365)*24)*60)*60)// test11.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;#define YEAR_SEC ((((1*365)*24)*60)*60)int _tmain(int argc, _TCHAR* argv[]){ cha.原创 2021-08-13 16:49:01 · 70 阅读 · 0 评论 -
面试题目123
#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ int i,j; int crr = 0; int mar[4][4]; for(i = 0; i < 4 ;i++) { for(j = 0; j < 4 ; j++) { mar[i][j] = crr; .原创 2021-08-13 15:37:56 · 43 阅读 · 0 评论 -
面试小题一二三
// test11.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ double a[2]={4,8} ,*p,*q; // p=&a[0]; p = a; q=p+1; std::cout...原创 2021-08-13 15:20:09 · 45 阅读 · 0 评论 -
数学与算法
该好好学习点算法知识,发现很多企业用到的算法都是并不复杂的,创新解决实际问题。 程序等于数据结构+算法。除了哗众的互联网、大数据、机器视觉、大量统计数据,动不动给你5亿条数据的运营商类公司,看看这个世界,凡解决痛点问题的,那个是移动电信联通之类运营商做出来的。 小精痛点问题,有一些技术完全可能是初中 高中数学能解决掉的。例如思想林俊德利用机械原理计算原子弹爆炸力学。而很多利...原创 2020-01-30 01:05:35 · 688 阅读 · 0 评论