What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
template
void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main()
{
int t1[] ={ 1, 7, 8, 4, 5 };
list
int t2[] ={ 3, 2, 6, 9, 0 };
list
l1.sort();
list
it++; it++;
l1.splice(l1.end(),l2, it, l2.end());
print(l1.begin(), l1.end()); cout<<"Size:"< print(l2.begin(), l2.end()); cout<<"Size:"< return 0; }
What will happen when you attempt to compile and run the following code?
#include
#include
#include
#include
#include
using namespace std;
int main() {
int t[] = { 3, 4, 2, 1, 0, 3, 4, 1, 2, 0 };
vector
multimap
for (vector
stringstream s;s << *i << *i;
m.insert(pair
}
pair
range = m.equal_range(2);
for (multimap
cout << i?>first << " ";
}
return 0;
}
The output will be:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
#include
using namespace std;
struct display {
void operator() (int i) {cout << " " << i;}
};
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector
deque
set
for_each(v1.begin(), v1.end(), display); //Line I
for_each(d1.begin(), d1.end(), *(new display())); // Line II
for_each(s1.begin(), s1.end(), display()); // Line III
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){} B(){}
int getV() const {return val;} };
ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); deque::iterator it = lower_bound(d1.begin(), d1.end(), 4); for_each(it, d1.end(), Out(cout));cout<<endl; return 0; } Program outputs: