c++面试题
文章平均质量分 52
wj199174
这个作者很懒,什么都没留下…
展开
-
字符数组
/////////////////////////////////////// 关于字符数组////////////////////////////////////// [8/24/2015 wangjian-pc]#include void func(char *str){printf("%d%d\n",sizeof(str),strlen(str)原创 2015-08-24 22:27:36 · 284 阅读 · 0 评论 -
字符数组比较
//////////////////////////////////////////////////// 关于字符数字的比较//////////////////////////////////////////////////// [8/24/2015 wangjian-pc]#include int main(){ char str1[] = "hello world"; ch原创 2015-08-24 23:05:26 · 781 阅读 · 0 评论 -
获取类成员的偏移量
// [8/24/2015 wangjian-pc]// 获取类成员的偏移量 #include struct Point3D{ int x; int y; int z;};int main(){ Point3D* pPoint = NULL; int offset = (int)(&(pPoint)->z); printf("%d", offset); sy原创 2015-08-24 23:52:10 · 583 阅读 · 0 评论 -
逻辑运算符与或
// [8/25/2015 wangjian-pc]#include bool fun1(char* str){ printf("%s\n", str); return false;}bool fun2(char* str){ printf("%s\n", str); return true;}int main(){ bool res1, res2; res原创 2015-08-25 00:05:57 · 406 阅读 · 0 评论 -
字符数粗的输出
// [8/24/2015 wangjian-pc]#include char* getString1(){ char p[] = "hello world"; return p;}char* getString2(){ char* p = "hello world"; return p;}int main(){ printf("getString1 retu原创 2015-08-24 23:23:06 · 284 阅读 · 0 评论 -
c++ 构造函数初始化列表
// [8/25/2015 wangjian-pc]// c++ 构造函数初始化列表#include class A{public: A():n2(0), n1(n2 + 2) {} void Print() { std::cout<< "n1:"<<n1<<",n2:"<<n2<<std::endl; }private: int n1; int n2;};原创 2015-08-25 00:25:26 · 288 阅读 · 0 评论 -
c++面试题
1、冒泡排序#includeusing namespace std;void bubbleSort(int a[],int length){ cout<<"排序前"<<endl; for (int i = 0; i < length; i++) { cout<<a[i]<<" "; } cout<<endl; for(int i=length; i>1; i--)原创 2015-08-10 00:07:51 · 333 阅读 · 0 评论