Wat*_*hul 2 c++ string compiler-errors g++
#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
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
这是代码,后面是编译的一部分。它只是头文件,其余代码尚未实现。我不明白为什么字符串不起作用。我也尝试使用分辨率运算符,但这并没有改变结果。
它不被称为string。它被称为std::string。
您可能已经看到了一些被称为的示例string。这是因为作者在using namespace std某处走了一条捷径和错处,尽管我们不一定建议这样做。