嘿伙计们,我刚刚开始学习C++,我有这个代码,我必须完成但是类标题给了我这个错误
错误:字符串:没有这样的文件或目录
#include <vector>
#include <string>
class Inventory
{
public:
Inventory ();
void Update (string item, int amount);
void ListByName ();
void ListByQuantity ();
private:
vector<string> items;
};
Run Code Online (Sandbox Code Playgroud)
您的代码应该看起来更像这样:
#include <string>
#include <vector>
class Inventory {
public:
Inventory();
void Update(const std::string& item, int amount);
void ListByName();
void ListByQuantity();
private:
std::vector<std::string> items;
};
Run Code Online (Sandbox Code Playgroud)
如果 #include <string>实际上是你的include指令,那么你可能正在将该文件编译为ac程序.编译器通常通过文件扩展名来确定语言.你的文件命名是什么?