C++ Primer
Primer
1. "显式"(explicit)和"隐式"(implicit)
隐式类型转换:编译器自动进行的类型转换,无需明确指定类型;
int x = 10; double y = x; // 隐式将整数转换为浮点数
显式类型转换:指定转换类型,避免隐式类型转换,可以在构造函数前使用 explicit ;
explicit TrieNode(std::map<char, std::shared_ptr<const TrieNode>> children) : children_(std::move(children)) {}
最后更新于
这有帮助吗?