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: 03 Jun, 2025
Question 1

What will happen when you attempt to compile and run the following code?
 #include <iostream>
 #include <string>
 using namespace std;
 template <class T>
 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>a("Hello"); string s(" world!");
 a.add(s);
 cout << a.getV() <<endl;
 return 0;
 }

Options :
Answer: A

Question 2

What will happen when you attempt to compile and run the following code?
 #include <iostream>
 #include <string>
 using namespace std;
 template <class T>
 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>a("Hello"); string s(" world!");
 a.add(s);
 cout << a.getV() <<endl;
 return 0;
 }

Options :
Answer: A

Question 3

What happens when you attempt to compile and run the following code?
 #include <deque>
 #include <iostream>
 #include <algorithm>
 using namespace std;
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}
 void operator() (const T & val ) { out<<val<<" "; } };
 int main() {
 int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
 deque<int> d1(t, t+10);
 sort(d1.begin(), d1.end());
 deque<int>::iterator it = upper_bound(d1.begin(), d1.end(), 4);
 for_each(it, d1.end(), Out<int>(cout));cout<<endl;
 return 0;
}
Program outputs:

Options :
Answer: A

Question 4

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <algorithm>
 #include <vector>
 #include <set>
 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<int> v1(10);fill(v1.begin(), v1.end(), sequence(1,1));
 for_each(v1.begin(), v1.end(), myfunction);
 return 0;
 }
Program outputs:

Options :
Answer: D

Question 5

What will happen when you attempt to compile and run the following code?
 #include <iostream>
 #include <string>
 using namespace std;
 template <class T>
 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>a("Hello"); string s(" world!");
 a.add(s);
 cout << a.getV() <<endl;
 return 0;
 }

Options :
Answer: A

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

© Copyrights CertsIQ 2025. 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.