小编Jos*_*son的帖子

c,按位,逻辑表达式

int x = 0;
x^=x || x++ || ++x;
Run Code Online (Sandbox Code Playgroud)

x的答案最后是3.如何分析这个表达式?对此有点困惑.非常感谢.

c

0
推荐指数
1
解决办法
217
查看次数

C++,迭代器问题

map <int, char*> testmap;
testmap[1] = "123";
testmap[2] = "007";
map<int, char*>::iterator p;

for(p = my_map.begin(); p != my_map.end(); p++) {
int len = strlen(p); // error here, why? thanks
cout << len << endl;
  cout << p->first << " : ";
  cout << p->second << endl;
}
Run Code Online (Sandbox Code Playgroud)

我在这个谎言上得到了错误:int len = strlen(p),我想获得数组的长度如何修复它?谢谢!

c++ iterator

0
推荐指数
1
解决办法
221
查看次数

C++成员初始化列表问题

class TreeNode {
   // An object of type TreeNode represents one node
   // in a binary tree of strings.
   public:
      // Constructor.  Make a node containing str.
      TreeNode(string str) : item(str), left(NULL), right(NULL) {}

      string item;      // The data in this node.
      TreeNode *left;    // Pointer to left subtree.
      TreeNode *right;   // Pointer to right subtree.
};
Run Code Online (Sandbox Code Playgroud)

在第6行,我可以删除这部分吗?

   : item(str), left(NULL), right(NULL)
Run Code Online (Sandbox Code Playgroud)

谢谢.

c++

0
推荐指数
1
解决办法
200
查看次数

c ++通过引用传递?

/*
    This program demonstrates a few routines for processing binary
    sort trees.  It uses a binary sort tree of strings.  The user
    types in strings.  The user's string is converted to lower case, and -- 
    if it is not already in the tree -- it is inserted into the tree.
    Then the number of nodes in the tree and a list of items in the tree
    are output.  The program ends when the user enters an empty string.
*/

#include …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
368
查看次数

在C++中实现double sqrt(double x)

double sqrt(double x)在不使用std库的情况下在C++中实现.

这是我在这里看到的Facebook面试问题.http://www.glassdoor.com/Interview/Implement-double-sqrt-double-x-in-C-QTN_87210.htm 还有其他任何好主意吗?...

!!!编辑.!!!(不使用std库.)

c++ sqrt

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

gnu C条件"如果"

我们得到if(expression) {...} 了例如.我们都知道如果表达式为真,它将在大括号中执行行.但是C中的"真实"是什么?那是!= 0表示我认为是真的吗?

谢谢

c gnu

0
推荐指数
1
解决办法
187
查看次数

C++库比较:Boost和Tr1

哪个更强大?因为我读过Linus Torvalds关于有多糟糕的文章.这是tr1比提升更好吗?

c++ boost tr1

0
推荐指数
1
解决办法
602
查看次数

C和C++之间有一个微妙的区别

以下C语句在C++中无效.

int *a = malloc(sizeof(*a));
Run Code Online (Sandbox Code Playgroud)

为什么?你是如何解决的?

答案是 :

C对void*执行隐式转换,而C++则不执行.使用显式转换来解决此问题.

我的问题是:明确投射到谁和哪里?谢谢.

c

0
推荐指数
1
解决办法
95
查看次数

C参数定义问题

当我想传递一个" char (*c)[10];"作为参数时,我应该在函数定义中定义什么参数?

我的意思是,如果我有一个功能:

void foo(*****) { ... }
Run Code Online (Sandbox Code Playgroud)

我想传递char (*c)[10];给它,所以我要写什么代替*****

c

0
推荐指数
1
解决办法
107
查看次数

数字为String的字符串,Unix C问题

我想使用abc1,abc2,abc3,abc4,.. abc100作为结构变量名.但我不知道如何设置这个?不知道.

有人可以帮帮我吗?非常感谢.

c string gcc ansi-c

-6
推荐指数
1
解决办法
192
查看次数

标签 统计

c ×5

c++ ×5

ansi-c ×1

boost ×1

gcc ×1

gnu ×1

iterator ×1

sqrt ×1

string ×1

tr1 ×1