![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c/c++
Marry Andy
断剑重铸之日,即是归来之时
展开
-
C语言有趣面试题
1. 第一次看这题直接蒙圈了,什么玩意,指针也能相减?返回指针差值? 经过与学长的激烈讨论才拿下这个“家伙”。int fun1(char *s){ char *p = s; while(*p++);//先*p 赋值,后自增,++和*平级 return p-s;}int fun2(char *s){ char *p = s; while(*++p);//原创 2018-04-01 16:10:08 · 234 阅读 · 0 评论 -
printf输出string类型出现的问题
#include <iostream>using namespace std;int main(void){ string a; a = "123"; char *b="123"; cout<<a<<endl; cout<<b<<endl; //printf("%s",a);报错 printf("%s\n",a.c_str());//正确原创 2018-04-13 17:20:38 · 580 阅读 · 0 评论 -
父类的protected,private必须赋值
#include <iostream>using namespace std;class Father{ protected: int a; int b; public: Father(); Father(int a,int b);};class Son:public Father{ public:原创 2018-04-13 18:00:16 · 580 阅读 · 0 评论 -
模板类
哇,今天的上机,上的我头皮发麻,题也蛮简单的,就是模板类的书写规则很复杂,如果记得不清楚,就会出错,还找不找错误在哪,mmp,一下为一些总结。template <typename T> void Swap(T &a,T &b){ T t; t = a; a = b; b = t;} //声明并实现模板函数前一定要加上template <typename *>,*为原创 2018-04-27 18:18:45 · 303 阅读 · 0 评论