최신 CPP 무료덤프 - C++ Institute C++ Certified Professional Programmer

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
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; }
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 = find_end (v.begin(), v.end(), m1, m1+3, Compare());
cout << "Found at position: " << it?v.begin() << endl;
return 0;
}

정답: C
What happens when you attempt to compile and run the following code?
# include <vector>
# include <set>
# 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 start++; } };
int main() {
vector<int> v1(10);
generate_n(v1.begin(), 10, Sequence(1));
random_shuffle(v1.rbegin(), v1.rend());
sort(v1.begin(), v1.end(), great<int>());
for_each(v1.begin(), v1.end(), Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:

정답: D
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 };
multiset<int> s1(t,t+10);
s1.insert(s1.find(7), 3);
for(multiset<int>::iterator i=s1.begin();i!= s1.end(); i++) {
cout<<*i<<" ";
}
return 0;
}

정답: E
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
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> v (t,t+15);
vector<int>::iterator it = search_n(v.begin(), v.end(), 4, 2);
cout<< it?v.begin()<<endl;
return 0;
}
Program outputs:

정답: B
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=0):val(v){}
int getV() const {return val;}
operator int () const { return 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<<" "; } };
struct Add {
B operator()(B & a, B & b) { return a+b; } };
int main() {
B t[]={1,2,3,4,5,6,7,8,9,10};
vector<B> v1(t, t+10);
vector<B> v2(10);
transform(v1.begin(), v1.end(), v2.begin(), bind2nd(Add(),1));
for_each(v2.rbegin(), v2.rend(), Out<B>(cout));cout<<endl;
return 0;
}
Program outputs:

정답: E
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
template<int>
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;
}

정답: C
What happens when you attempt to compile and run the following code? Choose all possible answers.
#include <iostream>
using namespace std;
class C {
public:
int _c;
C():_c(0){}
C(int c) { _c = c;}
C operator+=(C & b) {
C tmp; tmp._c = _c+b._c;
return tmp;
} };
ostream & operator<<(ostream & c, const C & v) {
c<<v._c; return c; }
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<int> b(2);
A<C>a (5);
a.add(C());
cout << a.getV() <<endl;
return 0;
}

정답: B,D
What happens when you attempt to compile and run the following code?
# include <iostream>
# include <deque>
# include <list>
# include <queue>
# include <vector>
using namespace std;
int main()
{
deque<int> mydeck;list<int> mylist; vector<int> myvector;
queue<int> first; queue<int> second(mydeck);
queue<int> third(second); queue<int, list<int> > fourth(mylist);
fourth.push(10);fourth.push(11);fourth.push(12);
queue<int, vector<int> > fifth(myvector);
fifth.push(10);fifth.push(11);fifth.push(12); // Line I
while(!fifth.empty())
{
cout<<fifth.front()<<" "; // Line II
fifth.pop(); // Line III
}
while (!fourth.empty())
{
cout << fourth.front() << " ";
fourth.pop(); // Line IV
}
return 0;
}

정답: E
What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
int main ()
{
int t[]={1,2,3,4,5};
std::vector<int>v1(t,t+5);
std::vector<int>v2(v1);
v1.resize(10);
v2.reserve(10);
std::vector<int>::iterator i = v1.begin();int ii = 0;
while (i != v1.end()) { std::cout<<i[ii]<<" ";ii??;i++; }
i = v2.begin();ii=0;
while (i != v2.end()) { std::cout<<i[ii]<<" ";ii??;i++; }
return 0;
}

정답: C
What happens when you attempt to compile and run the following code?
# include <vector>
# include <iostream>
# include <algorithm>
# include <functional>
using namespace std;
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
int Add(int a, int b) {
return a+b;
}
int main() {
int t[]={1,2,3,4,5,6,7,8,9,10};
vector<int> v1(t, t+10);
vector<int> v2(10);
transform(v1.begin(), v1.end(), v2.begin(), bind2nd(ptr_fun (Add),1));
vector<int>::iterator it = find_if(v2.begin(), v2.end(),bind2nd(equal_to<int>(),10)); cout<<*it<<endl;
return 0;
}
Program outputs:

정답: E
What happens when you attempt to compile and run the following code?
# include <vector>
# include <string>
# include <iostream>
# include <algorithm>
# include <ctype.h>
using namespace std;
template<typename T>class B { T val;
public:
B(T v):val(v){}
T getV() const {return 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<<" "; } };
string tolower(const string & s) {
string tmp(s);
for(unsigned i = 0; i< tmp.size(); ++i){
tmp[i] = tolower(tmp[i]); }
return tmp; }
bool Less(const B<string> &a, const B<string> &b) {
return tolower(a.getV())<tolower(b.getV()); }
int main() {
string t[]={"aaa","bbb","Aaa", "Bbb","aAa","bBb","aaA","bbB"};
vector<B<string> > v1; v1.assign(t, t+8);
stable_sort(v1.begin(), v1.end(), Less);
for_each(v1.begin(), v1.end(), Out<B<string> >(cout));cout<<endl;
return 0;
}
Program outputs:

정답: D
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;
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<int> l(t, t+10);
for_each(l.begin(), l.end(), Out<int>(f));
f.close(); f.open("test.out");
for( ; f.good() ; ) {
int i; f>>i;
cout<<i<<" ";
}
f.close();
return 0;
}

정답: B,C,D,E
Which stack initialization (line numbers) are correct? Choose all that apply.
# include <iostream>
# include <deque>
# include <list>
# include <stack>
# include <vector>
using namespace std;
int main()
{
deque<int> mydeck;
list<int> mylist;
vector<int> myvector;
stack<int> first;// Line I
stack<int> second(mydeck);// Line II
stack<int> third(second);// Line III
stack<int, list<int> > fourth(mylist);// Line IV
stack<int, vector<int> > fifth(myvector);// Line V
return 0;
}

정답: A,B,C,D,E
What happens when you attempt to compile and run the following code?
# include <deque>
# 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() {
int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};
deque<B> d1(t, t+10);
sort(d1.begin(), d1.end());
pair<deque<B> ::iterator, deque<B>::iterator > result = equal_range(d1.begin(), d1.end(),
B(20));
for_each(result.first, result.second, Out<B>(cout));cout<<endl;
return 0;
}
Program outputs:

정답: B
What happens when you attempt to compile and run the following code?
#include <list>
#include <iostream>
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;}
};
int main() {
int t1[] ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
list<A> l1(t1, t1 + 10);
list<A> l2(l1);
l2.reverse(); l1.splice(l1.end(),l2);
l1.pop_back();l1.unique();
print(l1.begin(), l1.end()); cout<<endl;
return 0;
}

정답: A
What happens when you attempt to compile and run the following code?
# include <deque>
# include <iostream>
# include <algorithm>
#include <set>
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[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
B t1[]={B(1),B(2),B(3),B(4)};
deque<B> d1(t, t+10);
set<B> s1(t, t+10);
sort(d1.begin(), d1.end());
cout<<includes(d1.begin(),d1.end(), t1,t1+4)<<" "<<includes(s1.begin(),s1.end(), t1,t1+4)
< <endl;
return 0;
}
Program outputs:

정답: C

우리와 연락하기

문의할 점이 있으시면 메일을 보내오세요. 12시간이내에 답장드리도록 하고 있습니다.

근무시간: ( UTC+9 ) 9:00-24:00
월요일~토요일

서포트: 바로 연락하기