Which sentence is correct about the code below?
#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; }
/* Insert Code Here */
};
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);
for_each(v1.begin(), v1.end(), add10());
vector::iterator it = find(v1.begin(), v1.end(), A(7));
cout << it?>getA() << endl;
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
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>v.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() { B t[]={3,2,4,1,5,10,9,7,8,6}; vector v1(t,t+10); sort(v1.begin(), v1.end(), greater()); cout<<*min_element(v1.begin(), v1.end()); return 0; } Program outputs:
Which stack initialization (line numbers) are correct? Choose all that apply.
#include
#include
#include
#include
#include
using namespace std;
int main()
{
deque
list
vector
stack
stack
stack
stack
stack
return 0;
}
What will happen when you attempt to compile and run the following code? Choose all possible answers.
#include
using namespace std;
class B {};
template
class A {
T_v;
public:
A() {}
A(T v): _v(v){}
T getV() { return _v; }
void add(T a) { _v+=a; }
};
int main()
{
A
Ab;
a.add(10);
cout << a.getV() < return 0; }
Lisa Rodriguez
25 days agoHyun Kim
1 month agoSharon Garcia
2 months agoEmi Hoang
2 months agoPatricia Lee
3 months agoNicolas Sidorov
3 months agoSharon Hall
4 months agoMatthew Morris
5 months agoKaren Hernandez
5 months agoEmma Reed
5 months agoJoseph Harris
5 months agoNancy Bailey
5 months agoWilliam Gonzalez
5 months agoAndrew Nguyen
5 months agoLoise
6 months agoKyoko
6 months agoDevora
6 months agoCarlota
7 months agoFletcher
7 months agoMajor
7 months agoGwen
7 months agoKris
8 months agoDonte
8 months agoKimberlie
8 months agoMarquetta
8 months agoGlory
9 months agoFatima
9 months agoOmega
9 months agoKristin
9 months agoPaz
9 months agoRose
10 months agoMarge
10 months agoGail
10 months agoDaren
10 months agoTarra
11 months agoFannie
11 months agoPearlie
11 months agoDonte
12 months agoSilva
12 months agoGiuseppe
12 months agoAileen
1 year agoSabra
1 year agoAnnmarie
1 year agoBuffy
1 year agoDyan
1 year agoSalena
2 years agoSalley
2 years agoArlean
2 years agoCaren
2 years agoAleisha
2 years agoLanie
2 years agoJohnetta
2 years agoChristiane
2 years agoStanford
2 years agoYuette
2 years agoDallas
2 years agoIndia
2 years agoAleisha
2 years agoRoselle
2 years agoVincenza
2 years agoLyda
2 years agoNoah
2 years agoMammie
2 years agoThea
2 years agoArlean
2 years agoMargarita
2 years ago