C++代码中string match_word(content,curi,len)是函数还是变量定义?
结论
match_word是std::string类型的局部变量,不是函数。
原理说明
你看到的是C++标准库std::string的构造函数调用语法,这里使用了std::string的官方构造重载:
basic_string( const basic_string& str, size_t pos, size_t count, const Allocator& alloc = Allocator() );
这段语法的作用是:
- 声明一个名为
match_word的std::string类型局部变量 - 从
content的curi下标位置开始,截取长度为len的子串,用来初始化match_word - 该变量的作用域仅在当前
if代码块内,离开块后就会自动销毁
为什么找不到定义
match_word是当前代码块内临时声明的局部变量,不是全局定义的函数或者全局变量,自然不会在头文件中存在对应的定义声明。
内容的提问来源于stack exchange,提问作者marlon
相关产品推荐
相关产品推荐

