C++ Institute CPP - C++ Certified Professional Programmer
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    template  ostream  & out;  Out(ostream & o): out(o){}  void operator() (const T & val ) { out<    int main() {  B t1[]={3,2,4,1,5};  B t2[]={5,6,8,2,1};  vector v1(10,0);  sort(t1, t1+5);  sort(t2, t2+5);  set_difference(t1,t1+5,t2,t2+5,v1.begin());  for_each(v1.begin(), v1.end(), Out(cout));cout<  return 0;  } Program outputs:
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;
}
struct sequence {
int val,inc;
sequence(int s, int i):val(s),inc(i){}
int operator()(){
int r = val; val += inc;
return r;
}
};
int main() {
 vector
fill(v1.begin(), v1.end(), sequence(1,1));
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs:
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()
{
 A
string s(" world!");
a.add(s);
 cout << a.getV() <  return 0;  }
Which lines of the code below contain proper instantiation of queue objects?
 #include 
 #include 
 #include 
 #include 
 #include 
using namespace std;
int main()
{
 deque
 list
 vector
 queue
 queue
 queue
 queue
 queue
return 0;
}
What happens when you attempt to compile and run the following code?
 #include 
 #include 
 #include 
 #include 
using namespace std;
 template
ostream & out;
Out(ostream & o): out(o){}
 void operator() (const T & val ) { out<  bool Greater(int v1, int v2) { return v1  int main() {  int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};  vector  sort(v1.begin(), v1.end(), Greater);  for_each(v1.begin(), v1.end(), Out  return 0;  } Program outputs:
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 };
 multiset
s1.insert(s1.find(7), 3);
 for(multiset
cout<<*i<<" ";
}
return 0;
}
What happens when you attempt to compile and run the following code? Choose all that apply.
 #include 
 #include 
using namespace std;
int main ()
{
 vector
v1.push_back(3);
 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:
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three
 #include 
 #include 
using namespace std;
int main ()
{
string a;
getline(cin, a);
What happens when you attempt to compile and run the following code?
 #include 
 #include 
 #include 
using namespace std;
 template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
  out<  }  };  struct Sequence {  int start;  Sequence(int start):start(start){}  int operator()() {   return start++;  } };  int main() {  vector  vector  generate(v1.begin(), v1.end(), Sequence(1));  random(v1.begin(),v1.end());  for_each(v1.begin(), v1.end(), Out  return 0;  } Program outputs:

 
                 
					