CPP 무료 덤프문제 온라인 액세스

시험코드:CPP
시험이름:C++ Certified Professional Programmer
인증사:C++ Institute
무료 덤프 문항수:230
업로드 날짜:2026-09-03
평점
100%

문제 1

What happens when you attempt to compile and run the following code?
# include <vector>
# include <set>
# include <iostream>
#include <algorithm>
using namespace std;
class B {
int val;
public:
B(int v):val(v){}
operator int() { return val;}
};
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
struct Sequence { int start;
Sequence(int start):start(start){}
int operator()() { return start++; } };
bool predicate(int v) { return v%2==0; }
int main() {
vector<int> v1(10);
generate_n(v1.begin(), 10, Sequence(1));
for_each(v1.begin(), remove_if(v1.begin(), v1.end(), predicate),
Out<int>(cout));cout<<endl;
return 0;}
Program outputs:

문제 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;
}

문제 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<<" "; } };
struct Sequence { int start;
Sequence(int start):start(start){}
int operator()() {return 10*(1+(start++ %3));}
};
int main() {
deque<int> d1(10);
generate(d1.begin(), d1.end(), Sequence(1));
sort(d1.begin(), d1.end());
pair<deque<int>::iterator, deque<int>::iterator > result = equal_range(d1.begin(), d1.end(),
20);
for_each(result.first, result.second, Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:

문제 4

What will happen when you attempt to compile and run the following code?
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
int main ()
{
vector<int>v1;
deque<int>d1;
for(int i=0; i<5; i++)
{
v1.push_back(i);v1.push_front(i);
d1.push_back(i);d1.push_front(i);
}
for(int i=0; i<d1.size(); i++)
{
cout<<d1[i]<<" "<<v1[i]<<" ";
}
cout<<endl;
return 0;
}
What will be its output:

문제 5

What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
using namespace std;
class A
{
int a;
public:
A():a(0){} A(int a){ this?>a = a;}
void setA(int a) {this?>a = a;}
int getA() {return a;}
};
ostream &operator<<(ostream & cout, A & a)
{
cout<< a.getA();
return cout;
}
int main ()
{
vector<A*>v(5, new A());
v.push_back(new A(1));
vector<A*>::iterator it;
for(it = v.begin(); it != v.end(); it++)
{
cout<<*it<<" ";
}
cout<<endl;
return 0;
}

댓글 추가

귀하의 메일주소는 공개되지 않습니다. 필수 입력 사항은 표시되어 있습니다. *

insert code
그림의 인증번호를 입력하세요.