我是否正确宣布了这一点?
string regular = "TEST";
long[] cipher = new long[regular.length()];
获取此编译错误:expected unqualified-id before '[' token
答案 0 :(得分:8)
new
表达式返回指针,因此cipher
必须为1:
long *cipher = new long[regular.length()];
但是使用原始数组很容易出错。考虑替换std::vector
代替:
std::vector<long> cipher(regular.length());