My problem is that I'm getting the warning C4715 again and I have no clue why...
I'm aware of possible undefined beahviour and already checked definitions. Please help a newbie in need.
#edit - of course im missing 'algorithm' but that doesnt solve problem.
#include <iostream>
#include <vector>
int solve(std::vector<int> v) {
for (int i = 0; i < v.capacity(); i++) {
auto result1 = std::find(v.begin(), v.end(), -v[i]);
if (result1 != v.end())
std::cout << "v contains the opposite of: " << v[i] << '\n';
else {
std::cout << "v doesnt have match to: " << v[i] << '\n';
return v[i];
}
}
}
int main() {
std::vector<int> v{ {1,-1,2,-2,3} };
std::cout << solve(v);
return 0;
}
" if the for loop ends, you have no return " - credit to @Berto99
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.