Higher Test Marks with Free Online CPP-22-02 Exam Practice

Assess the CertsIQ’s updated CPP-22-02 exam questions for free online practice of your CPP - C++ Certified Professional Programmer test. Our CPP 22 02 dumps questions will enhance your chances of passing the C++ Certified Professional Programmer certification exam with higher marks.

Exam Code: CPP-22-02
Exam Questions: 230
CPP - C++ Certified Professional Programmer
Updated: 15 Jan, 2026
Question 1

What happens when you attempt to compile and run the following code?
 #include <iostream>
 using namespace std;
 template<class A>
 void f(A a)
 {
 cout<<1<<endl;
 }
 void f(int a)
 {
 cout<<2<<endl;
 }
 int main(){
 int a = 1;
 f<float>(a);
 return 0;
 }

Options :
Answer: A

Question 2

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <set>
 #include <vector>
 using namespace std;
 int main(){
 int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
 vector<int>v(t, t+10);
 multiset<int> s1(v.begin(),v.end());
 s1.insert(v.begin(),v.end());
 pair<multiset<int>::iterator,multiset<int>::iterator> range;
 range = s1.equal_range(6);
 while (range.first != range.second) {
 cout<<*range.first<<" "; range.first++;
 }
 return 0;
 }

Options :
Answer: A

Question 3

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <algorithm>
 #include <vector>
 using namespace std;
 class A {
 int apublic:
 A(int a) : a(a) {}
 int getA() const { return a; } void setA(int a) { this?>a = a; }
 bool operator==(A & b) { return a == b.a; }
 };
 struct Compare{
 bool operator()(const A & a, const A & b) {return a.getA()==b.getA();};
 };
 int main () {
 int t[] = {1,2,3,4,5,1,2,3,4,5};
 vector<A> v (t,t+10);
 vector<A>::iterator it;
 A m1[] = {A(1), A(2), A(3)};
 it = search (v.begin(), v.end(), m1, m1+3, Compare());
 cout << "First found at position: " << it?v.begin() << endl;
 return 0;
 }
Program outputs:

Options :
Answer: B

Question 4

What happens when you attempt to compile and run the following code?
 #include <deque>
 #include <iostream>#include <algorithm>
 #include <functional>
 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<<v.getV(); return out;}
 template<class T>struct Out {
 ostream & out; Out(ostream & o): out(o){}
 void operator() (const T & val ) { out<<val<<" "; } };
 int main() {
 int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};
 deque<B> d1(t, t+10);
 sort(d1.begin(), d1.end(), greater<B>());
 pair<deque<B> ::iterator, deque<B>::iterator > result = equal_range(d1.begin(), d1.end(),
B(20), greater<B>());
 for_each(result.first, result.second, Out<B>(cout));cout<<endl;
 return 0;
 }
Program outputs:

Options :
Answer: B

Question 5

What happens when you attempt to compile and run the following code?
 #include <vector>
 #include <iostream>
 #include <algorithm>
 using namespace std;
 template<typename T>class B { T val;
 public:
 B(T v):val(v){}
 T getV() const {return val;} bool operator < (const B & v) const { return val<v.val;} };
 template<class T>ostream & operator <<(ostream & out, const B<T> & v) { out<<v.getV();
return out;}
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}void operator() (const T & val ) { out<<val<<" "; } };
 bool Less(const B<float> &a, const B<float> &b) { return int(a.getV())<int(b.getV());}
 int main() {
 float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13};
 vector<B<float> > v1; v1.assign(t, t+10);
 stable_sort(v1.begin(), v1.end(), Less);
 for_each(v1.begin(), v1.end(), Out<B<float> >(cout));cout<<endl;
 return 0;
 }
Program outputs:

Options :
Answer: A

Viewing Page : 1 - 23
Practicing : 1 - 5 of 230 Questions

© Copyrights CertsIQ 2026. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (CertsIQ). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the CertsIQ.