自动C 关键字有什么作用
What does the auto c++ keyword do?
我最近在C 中获得了关键字自动。
在代码中:
auto maxIterator = std::max_element(&spec[0], &spec[sampleSize]);
float maxVol = *maxIterator;
// Normalize
if (maxVol != 0)
std::transform(&spec[0], &spec[sampleSize], &spec[0], [maxVol] (float dB) -> float { return dB / maxVol; });
这与在音频流上运行频率分析有关。从网站:http://katyscode.wordpress.com/2013/01/16/cutting-your-teeth-teeth-fmod-part-part-part-4-frequency-4-frequency-analysis-graphic- equarpaphic-equalizer-equalizer-beat-detection and-bpm-估计/
我搜索了论坛,但它说关键字没有用。有人可以在这里解释它的用途吗?
我是C 的新手,所以请尽量不要使答案变得太复杂。非常感谢。
自动使麦克西托也成为指针吗?
编译器猜测maxIterator
的类型。如果spec
的类型为float []
,则maxIterator
类型为float *
。
在C 11中,关键字auto
从其初始化表达式中推论已声明的变量的类型。因此,在您的代码中,它推论了maxIterator
的类型。
有关auto
的更多信息,请
相关文章:
- archive_read_support_filter_all() 有什么作用?
- 当我们为(;;) 写作时,它做了什么?for 循环中的双分号有什么作用?
- 这个递归函数有什么作用?运行时的复杂性是多少?
- DrawShadow 中的 Elevation 究竟有什么作用?
- 测试"stream >> char"有什么作用?
- "uFlags &= ~CHN_PANNING"命令有什么作用?
- GCC 的 -Wpsabi 选项究竟有什么作用?压制它意味着什么?
- int** a = new int*[n]();这个函数有什么作用?
- C++ 此函数调用之前的(void)有什么作用?
- i+=(i&-i) 有什么作用?它是便携式的吗?
- 这个size_t在 lambda 中有什么作用?C++代码
- 数组下标运算符 ([ ]) 对数组有什么作用?
- 结构之外的节点 * head 有什么作用?
- 重载括号运算符有什么作用?
- clang的"-Ofast"选项在实践中有什么作用,特别是对于与gcc的任何差异?
- std::make_unique_for_overwrite() 对 std::make_unique() 有什么作用?
- 运算符 delete[] 有什么作用?
- 下面的代码有什么作用?c++
- 这个陈述'p = I.ptr<uchar>(i);有什么作用?
- 这个嵌套的名称空间定义有什么作用