我有一个递归功能,我正在排除故障.我想输出递归深度...即函数调用自身的次数.
如果我使用一个静态变量,该变量在函数顶部递增,在底部递减.
这会准确地给我深度水平吗?
recurse()
{
static int depth = 0;
depth++;
/*
do stuff
recurse()
*/
depth--;
return return_value;
}
Run Code Online (Sandbox Code Playgroud) 我知道*定义一个指针... **确定一个指向指针的指针?
如果是这样,为什么?
指针指针有时被称为引用吗?只需要澄清以下非常简单的哈希.
通常,当传递整个内容时,指针用于传递较大结构的位置.
我已经看到指向用于在quantlib项目中使用的指针的指针来创建"句柄",因为每个"观察者"都拥有一个指向"术语结构"指针的指针,该指针可能在运行时发生变化,因此指针保持另一个指针的位置.
但是我看到这里没有相关性?
class hash_entry
{
private:
int key;
int value;
public:
hash_entry(int key, int value)
{
this->key = key;
this->value = value;
}
int getKey()
{
return key;
}
int getValue()
{
return value;
}
};
class hash_map
{
private:
hash_entry **table;
static const int TABLE_SIZE = 128;
public:
hash_map()
{
table = new hash_entry*[TABLE_SIZE];
for (int i = 0; i < TABLE_SIZE; i++)
table[i] = NULL;
}
int get(int key)
{ …Run Code Online (Sandbox Code Playgroud)