for (unsigned int i = 1; i <= 100; i++) {
if (i & 0x00000001) {
std::cout << i<<",";
}
}
Run Code Online (Sandbox Code Playgroud)
为什么(以及如何):if( i & 0x00000001 )找出奇数?
我注意到C++中有密封和接口关键字.这仅适用于CLR C++吗?如果没有,什么时候密封和接口添加到C++标准?它们在C++中的含义与它们在C#中的含义相同吗?如果没有,我如何获得标准C++中的等价物?
我在网站上发现了这段代码,似乎作者早已不见了,无论如何,我很难理解实际的交换以及如何发生相反的情况:
void strrev2(char *str)
{
if( str == NULL )
return;
char *end_ptr = &str[strlen(str) - 1];
char temp;
while( end_ptr > str )
{
temp = *str;
*str++ = *end_ptr;
*end_ptr-- = temp;
}
}
Run Code Online (Sandbox Code Playgroud)
让我们说你喂它"测试"这个词
第一次迭代:
*end_ptr = 'g';
temp = 't'
*str = 'g' // is it first assigned and then incremented to point to the next location?
*end_ptr = 't' // is it first assigned and then decremented to point to the previous location?
Run Code Online (Sandbox Code Playgroud)
第二次迭代会发生什么?我很难过,因为我觉得这就行了:
char …Run Code Online (Sandbox Code Playgroud) 如何使用binder2nd,bind2nd和bind1st?更具体地说何时使用它们并且它们是否必要?另外,我正在寻找一些例子.