What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
#include
using namespace std;
class A {
int a;
public:
A(int a):a(a) {}
int getA() const { return a;} void setA(int a){ this?>a = a;}
bool operator < ( const A & b) const { return a }; struct display { void operator() (const A & a) {cout << " " << a.getA();} }; struct add10 { void operator() (A & a) { a.setA(a.getA()+10) ;} }; int main() { int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vector v1(t, t + 10); set s1(t, t + 10); for_each(v1.begin(), v1.end(), add10()); for_each(v1.begin(), v1.end(), display()); for_each(s1.begin(), s1.end(), add10()); for_each(s1.begin(), s1.end(), display()); return 0; }
What happens 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);
void add(string & a);
};
template
void A
void A
_v.insert(0, a);
}
int main()
{
A
string s(" world!");
a.add(s);
cout << a.getV() < return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
void print(T start, T end)
{
while (start != end)
cout<<*start++;
}
int main ()
{
string t[] = {"one", "two" ,"three" ,"four", "five"};
vector
deque
d1.push_back("zero");
print(d1[0].rbegin(),d1[0].rend());
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main(){
int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };
string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"};
map
for(int i=0; i<10; i++) {
m.insert(pair
}
if (m[11] == "eleven") {
cout<<"eleven ";
}
for(map
cout<second<<" ";
}
cout< 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){}
int getV() const {return val;} bool operator < (const B & v) 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}; set s1(t, t+10); sort(s1.begin(), s1.end()); for_each(s1.begin(), s1.end(), Out(cout));cout< return 0; } Program outputs:
Carlota
4 days agoFletcher
11 days agoMajor
18 days agoGwen
27 days agoKris
1 month agoDonte
1 month agoKimberlie
2 months agoMarquetta
2 months agoGlory
2 months agoFatima
2 months agoOmega
3 months agoKristin
3 months agoPaz
3 months agoRose
3 months agoMarge
4 months agoGail
4 months agoDaren
4 months agoTarra
4 months agoFannie
5 months agoPearlie
5 months agoDonte
5 months agoSilva
5 months agoGiuseppe
6 months agoAileen
6 months agoSabra
6 months agoAnnmarie
6 months agoBuffy
9 months agoDyan
11 months agoSalena
1 year agoSalley
1 year agoArlean
1 year agoCaren
1 year agoAleisha
1 year agoLanie
1 year agoJohnetta
1 year agoChristiane
1 year agoStanford
1 year agoYuette
1 year agoDallas
1 year agoIndia
1 year agoAleisha
1 year agoRoselle
1 year agoVincenza
1 year agoLyda
2 years agoNoah
2 years agoMammie
2 years agoThea
2 years agoArlean
2 years agoMargarita
2 years ago