Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试在 .h 文件中声明带有字符串参数的函数时,会发生错误。我没有忘记包含 string.h =) 当我使用 char[] 时,一切都很好,但我希望参数是一个字符串。
string.h在 C++ 中不存在。你string的意思是(没有.h)?此外,string该类位于std您需要限定类型用法的命名空间中:
string.h
string
.h
std
std::string timeToStr(std::string);
如果您发布了确切的错误消息和重现错误的代码,这将很有帮助。
尝试
#include <string>
代替
#include <string.h>
它们是不同的东西——string.h 是 CRT,string 是 STL。