CPP - C++ Certified Professional Programmer 온라인 연습
최종 업데이트 시간: 2026년02월14일
당신은 온라인 연습 문제를 통해 C++ Institute CPP-22-02 시험지식에 대해 자신이 어떻게 알고 있는지 파악한 후 시험 참가 신청 여부를 결정할 수 있다.
시험을 100% 합격하고 시험 준비 시간을 35% 절약하기를 바라며 CPP-22-02 덤프 (최신 실제 시험 문제)를 사용 선택하여 현재 최신 230개의 시험 문제와 답을 포함하십시오.
/ 6
Question No : 1
What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
#include <algorithm>
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() {
B t[]={3,2,4,1,5,10,9,7,8,6};
vector<B> v1(t,t+10);
sort(v1.begin(), v1.end(), greater<B>());
cout<<*min_element(v1.begin(), v1.end());
return 0;
}
Program outputs:
정답:
Question No : 2
What happens when you attempt to compile and run the following code? Choose all that apply.
#include <iostream>
#include <fstream>
#include <string>
#include <list>
#include <algorithm>
#include <iomanip>
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
operator int() const { return val; };};
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) {out<<setw(3)<<hex<<val; } };
int main () {
int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
fstream f("test.out", ios::trunc|ios::out);
list<B> l(t, t+10);
for_each(l.begin(), l.end(), Out<B>(f));
f.close();
f.open("test.out");
for( ; f.good() ; ) {
int i;
f>>i;
cout<<i<<" ";
}
f.close();
return 0;
}
정답:
Question No : 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);
deque<int>::iterator it = lower_bound(d1.begin(), d1.end(), 4);
for_each(it, d1.end(), Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:
정답:
Question No : 4
Which changes introduced independently will allow the code to compile and display 0 0 1 1 8 8 9 9
(choose all that apply)?
#include <iostream>
#include <set>
#include <vector>
using namespace std;
class A {
int a;
public:
A(int a):a(a){}
int getA() const { return a;}
/* Insert Code Here 1 */
};
/* Insert Code Here 2*/
int main(){
A t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
set<A>s(t, t+10);/* Replace Code Here 3 */
multiset<A> s1(s.begin(),s.end());/* Replace Code Here 4 */
s1.insert(s.begin(),s.end());
s1.erase(s1.lower_bound(2),s1.upper_bound(7));
multiset<A>::iterator i=s1.begin();/* Replace Code Here 5 */
for( ;i!= s1.end(); i++)
{
cout<<i?>getA()<<" ";
}
cout<<endl;
return 0;
}
정답:
Question No : 5
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main() {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
vector<int> v1(t, t + 15);
set<int> s1(t, t + 15);
pair<set<int>::iterator, vector<int>::iterator > resultSet = mismatch(s1.begin(), s1.end(),
v1.begin());
cout<<*resultSet.first<<" "<<*resultSet.second<<endl;
return 0;
}
Program outputs:
정답:
Question No : 6
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;
struct display {
void operator() (int i) {cout << " " << i;}
};
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector<int> v1(t, t + 10);
deque<int> d1(t, t + 10);
set<int> s1(t, t + 10);
for_each(v1.begin(), v1.end(), display); //Line I
for_each(d1.begin(), d1.end(), *(new display())); // Line II
for_each(s1.begin(), s1.end(), display()); // Line III
return 0;
}
정답:
Question No : 7
What will happen when you attempt to compile and run the code below, assuming that you enter
the following sequence: 1.1 2.2 3.3<enter>?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
cout<<a<<b<<c<<endl;
return 0;
}
Program will output:
정답:
Question No : 8
What happens when you attempt to compile and run the following code?
#include <vector>
#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 t1[]={3,2,4,1,5};
int t2[]={6,10,8,7,9};
vector<int> v1(10);
sort(t1, t1+5);
sort(t2, t2+5);
merge(t1,t1+5,t2,t2+5,v1.begin());
for_each(v1.begin(), v1.end(), Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:
정답:
Question No : 9
What happens when you attempt to compile and run the following code?
#include <list>
#include <iostream>
#include <deque>
using namespace std;
template<class T> void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
class A {
int a;
public:
A(int a):a(a){}
operator int () const { return a;}int getA() const { return a;}
};
struct R {
int val;
R(int v):val(v){}
bool operator ()(const A & a) { return a>val;} };
int main() {
int t1[] ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
list<A> l1(t1, t1 + 10);
R r(4);l1.remove_if(r);
print(l1.begin(), l1.end()); cout<<endl;
return 0;
}
정답:
Question No : 10
What happens when you attempt to compile and run the following code?
#include <vector>
#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 t1[]={3,2,4,1,5};
int t2[]={5,6,8,2,1};
vector<int> v1(10);
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<int>(cout));cout<<endl;
return 0;
}
Program outputs:
정답:
Question No : 11
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void g(int a)
{
cout<<a?1<<endl;
}
template<class A>
void g(A a)
{
cout<<a+1<<endl;
}
int main()
{
int a = 1;
g(a);
return 0;
}
정답:
Question No : 12
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
template <typename T>
class A {
T_v;
public:
A() {}
A(T v): _v(v){}
T getV() { return _v; }
void add(T a) { _v+=a; }
template <class U>
U get(U a) {
return (U)(_v);
}
};
int main()
{
A<int> a(1);
a.add(10);
cout.setf( ios::showpoint);
cout << a.getV() << " " << a.get(1.0)<<endl;
return 0;
}
정답:
Question No : 13
What happens when you attempt to compile and run the following code?
include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector<int> v1(t, t + 10);
deque<int> d1(t, t + 10);
set<int> s1(t, t + 10);
cout<<find(v1.begin(), v1.end(), 6)<<" "<<find(d1.begin(), d1.end(), 6)<<" "<<find(s1.begin(),
s1.end(), 6);
return 0;
}
정답:
Question No : 14
What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
int main ()
{
std::vector<int>v1;
for(int i = 10; i>0; i??)
{
v1.push_back(i);
}
std::vector<int>::iterator it = v1.begin();
int sum = 0;
while(it != v1.end())
{
sum+=it++;
}
std::cout<<*v1.erase(v1.begin(),v1.end()?3)<<" "<<sum <<std::endl;
return 0;
}
정답:
Question No : 15
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <deque>
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; }
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
deque<int> d (t,t+15);
int number = count(d.begin(), d.end(), 2);
cout<< number<<endl;
return 0;
}
Program outputs: