Prepare for the C++ Institute CPP - C++ Certified Professional Programmer Exam exam with our extensive collection of questions and answers. These practice Q&A are updated according to the latest syllabus, providing you with the tools needed to review and test your knowledge.
QA4Exam focus on the latest syllabus and exam objectives, our practice Q&A are designed to help you identify key topics and solidify your understanding. By focusing on the core curriculum, These Questions & Answers helps you cover all the essential topics, ensuring you're well-prepared for every section of the exam. Each question comes with a detailed explanation, offering valuable insights and helping you to learn from your mistakes. Whether you're looking to assess your progress or dive deeper into complex topics, our updated Q&A will provide the support you need to confidently approach the C++ Institute CPP exam and achieve success.
Given three files: class.h, class.cpp and main.cpp containing small C++ project, which sentences are TRUE if you attempt to compile and run the program? Assume that the whole compiling environment is properly set.
// File: main.cpp
#include
#include "class.h"
using namespace std;
int main()
{
A
cout << a.getV() << endl;
return 0;
}
//File: class.h
#ifndef _CLASS_
#define _CLASS_
template
class A {
T_v;
public:
A() {}
A(T v);
T getV();
};
#endif
//File: class.cpp
#include "class.h"
template
A
template
T A
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out< } }; struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return 10*(1+(start++ %3)); } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); sort(v1.rbegin(), v1.rend()); unique_copy(v1.begin(),v1.end(), v2.begin()); for_each(v2.begin(), v2.end(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
map
for(int i=0; i < 10; i++) {
m[i]=t[i];
}
map
cout<
return 0;
}
Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){} B(){}
int getV() const {return val;} };
ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); deque::iterator it = lower_bound(d1.begin(), d1.end(), 4); for_each(it, d1.end(), Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out< struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); reverse_copy(v1.begin(),v1.end(), v2.rbegin()); sort(v2.begin(), v2.end(), less_equal for_each(v2.begin(), v2.end(), Out return 0; } Program outputs:
Full Exam Access, Actual Exam Questions, Validated Answers, Anytime Anywhere, No Download Limits, No Practice Limits
Get All 228 Questions & Answers