C++
文章平均质量分 66
手软脚软
这个作者很懒,什么都没留下…
展开
-
explicit使用注意事项
explicit作用* 在C++中,只含一个参数的构造函数会隐式进行类型转换(implicit conversions)。* 比如用int型向只含有Type*的的单参构造函数时,就会发生隐式的转换,int型被隐式转成Type*指针。这种情况有时不是我们想要的。* 这个时候,我们可以用C++的关键字explicit来限制这种隐式转换。使用后,我们就只能用正确的类型的参数传参。explicit使用注意原创 2013-02-24 11:15:31 · 386 阅读 · 0 评论 -
join使用
// 在日常开发中,经常会碰到需要将多个字符串以某些相同的分隔字符串连接起来的情形 // "select * from t where name in ('a', 'b', .. , 'z')"中的"', '" // "insert into t(name) values ('a'), ('b')"中的 "'), ('" // ab a 中的 "" //原创 2013-03-01 23:04:59 · 283 阅读 · 0 评论 -
偶遇C++怪异语法
在技术论坛上闲逛时,看到一个奇怪的C++语法:offset[array] 跟我们常见的array[offset]语法不一样 这也是C++合法的语法?于是进行了验证,代码如下: #include using namespace std; int main(int argc, char** argv) { int arr_a[10] = {1,2,4}; cout <<原创 2013-03-24 16:37:34 · 630 阅读 · 0 评论 -
不同基本类型的引用,隐晦的转换
#include using namespace std; int main(int argc, char** argv) { int a = 0; int b = 0; const int& ref_a = a; const short& ref_b = b; a = 1;原创 2013-03-24 17:06:57 · 474 阅读 · 0 评论