我有以下代码
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
string d="georgia is nice country":
string::iterator my;
for (my=d.begin();my!=d.end();my++) {
cout<<*my<<endl;
}
return 0;
}
但它会导致编译器错误,说“我的未定义”。有什么问题?
答案 0 :(得分:1)
string d="georgia is nice country"; // <-- semicolon, not colon
答案 1 :(得分:1)
你需要在字符串后加一个分号而不是冒号。
string d="georgia is nice country"; // <-- semicolon!