#ifndef MENU_H
#define MENU_H
#include <cstring>
#include <string>
#include <cctype>
class Menu{
public:
Menu();
void run();
int selectOptions();
void rotate90();
void rotate180();
void rotate270();
void flipVert();
void flipHoriz();
void convertHigh(int threshold);
void saveImage(string saveName);
void loadImage(string loadName);
void displayMenu();
private:
}
#endif // MENU_H
C:\Users\Wattenphul\Documents\alg-prog design\project04>g++ -std=c++11 -o main.exe main.cpp menu.cpp
In file included from menu.cpp:6:
menu.h:22:20: error: 'string' has not been declared
void saveImage(string saveName);
^~~~~~
menu.h:22:35: error: expected ',' or '...' before 'saveName'
void saveImage(string saveName);
^~~~~~~~
menu.h:23:20: error: 'string' has not been declared
void loadImage(string loadName);
^~~~~~
menu.h:23:35: error: expected ',' or '...' before 'loadName'
void loadImage(string loadName);
^~~~~~~~
menu.h:28:2: error: expected ';' after class definition
}
这是编译后的代码。这只是头文件,其余代码尚未实现。我不明白为什么该字符串不起作用。我也尝试使用解析运算符,但这并没有改变结果。
最佳答案
它不被称为字符串
。它被称为std::string
。
您可能已经看到过一些将其称为字符串
的示例。那是因为作者走了一条捷径,并在某处错误地使用了命名空间 std,但 we don't necessarily recommend doing that .
关于c++ - 我不明白尝试使用字符串作为函数参数时遇到的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59107135/