
面试
yunwen3344
这个作者很懒,什么都没留下…
展开
-
不用+ - * / 实现两个整数的相加
int add(int a,int b){ char * c; c = (char *) a; return &c[b];} 以上在vc中由于类型不匹配,编译不通过,可以使用下面的方法 int AddWithoutArithmetic(int a,int b) { if(b==0) return a; int sum=a^b; //将各位相加,不考虑进位 int carry=(原创 2013-03-01 14:20:30 · 566 阅读 · 0 评论 -
c++中构造函数调用另一构造函数的问题,如何避免生成临时对象
转自: http://blog.chinaunix.net/uid-26611383-id-3549733.html 题目如下:问下列代码的打印结果为0吗? #include #include using namespace std; struct CLS { int m_i; CLS( int i ) : m_i(i){}转载 2014-12-01 14:13:21 · 1181 阅读 · 0 评论