class Solution {
public:
int finalValueAfterOperations(vector<string>& operations) {
int x = 0;
for (auto &op : operations) {
if (op == "X++" || op == "++X") {
x++;
} else {
x--;
}
}
return x;
}
};
现在大一c++刚学到多态,在LeetCode里找了一道最简单的数组题,发现很多东西都没见过,比如这个函数中的参数表,这个形式没见过,还有for中的auto &op:这些都没见过。
感觉现在学的c++好多格式都和c一样,感觉就是在用c++的部分语法写c语言,请问我该怎么学习啊
感谢回答!