What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main ()
{
std::vector
v1.push_back(10);
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
bool classifier(int v) {
return v%2==0;
}
int main() {
int t[] = { 1, 5, 2, 5, 2, 4, 4, 3, 3, 1 };
vector
set
replace(v1.begin(), v1.end(),classifier, 10);
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs:
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
using namespace std;
template
class A {
T_v;
public:
A(T v);
};
template