What will happen when you attempt to compile and run the following code? #include #include using namespace std; template class A { T_v; public: A() {} A(T v): _v(v){} T getV() { return _v; } void add(T & a) { _v+=a; } }; int main() { Aa("Hello"); string s(" world!"); a.add(s); cout << a.getV() <
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; int main(){ int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; vectorv(t, t+10); multiset s1(v.begin(),v.end()); s1.insert(v.begin(),v.end()); pair::iterator,multiset::iterator> range; range = s1.equal_range(6); while (range.first != range.second) { cout<<*range.first<<" "; range.first++; } return 0; }
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; templateclass B { T val; public: B(T v):val(v){} T getV() const {return val;} bool operator < (const B & v) const { return valostream & operator <<(ostream & out, const B & v) { out<struct Out { ostream & out; Out(ostream & o): out(o){}void operator() (const T & val ) { out< &a, const B &b) { return int(a.getV()) > v1; v1.assign(t, t+10); stable_sort(v1.begin(), v1.end(), Less); for_each(v1.begin(), v1.end(), Out >(cout));cout<