What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;
bool identical(int a, int b) {
return b == 2*a?true:false;
}
int main() {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
int u[] = {2,4,6,4,6,10,2,4,14,6,4,2,20,8,8,5};
vector<int> v1(t, t + 15);
deque<int> d1(u, u + 15);
pair<deque<int>::iterator, vector<int>::iterator > result;
result = mismatch(d1.begin(), d1.end(), v1.begin(), identical); //Line I
if (result.first == d1.end() && result.second == v1.end()) { //Line II
cout<<"Identical\n";
} else {
cout<<"Not identical\n";
}
return 0;
}
Program outputs:
- Identical
- Not identical
- compilation error at line marked I
- compilation error at line marked II
Reveal Solution
Next Question