小编Sem*_*kül的帖子

当逗号分隔的for循环的条件部分中有多个表达式时会发生什么?

我这里有一个无限循环,但为什么呢?

int end = 5;
for(int i = 0; i < end, printf("at condition i=%d\n",i); ++i) 
{
    printf("inside i=%d\n",i);
}
Run Code Online (Sandbox Code Playgroud)

c syntax loops comma-operator

2
推荐指数
1
解决办法
140
查看次数

使用分配的局部变量来返回函数的值或直接使用函数

这有什么区别:

MyClass c = getMyClass();
calculate(c.value);
Run Code Online (Sandbox Code Playgroud)

还有这个:

calculate(getMyClass().value);
Run Code Online (Sandbox Code Playgroud)

在性能和内存分配范围?

c++ compiler-construction performance

2
推荐指数
1
解决办法
60
查看次数