Free CPP Exam Braindumps (page: 16)

Page 16 of 58

What happens 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; }

void add(string & a) {
_v.insert(0, a);
}

};

int main()
{
A<string> a("Hello");
string s(" world!");
a.add(s);
cout << a.getV() <<endl;
return 0;
}

  1. program will display: Hello world!
  2. compilation error
  3. program will display: world!Hello
  4. program will run without any output

Answer(s): B



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<<" "; }};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() {
return start++; } };
int main() {
vector<int> v1(10);
vector<int> v2(10);
generate(v1.begin(), v1.end(), Sequence(1));
reverse_copy(v1.begin(),v1.end(), v2.rbegin());
sort(v2.begin(), v2.end(), less_equal<int>());
for_each(v2.begin(), v2.end(), Out<int>(cout) );cout<<endl;
return 0;
}

Program outputs:

  1. 1 2 3 4 5 6 7 8 9 10
  2. 10 9 8 7 6 5 4 3 2 1
  3. no output
  4. compilation error

Answer(s): A



What happens when you attempt to compile and run the following code?

#include <iostream>
#include <algorithm>
#include <set>
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 < (const A & b) const { return a<b.a;}
};
struct Compare {
bool operator ()(A & a) {
if (a.getA() < 5) return true;
return false;
}
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
set<A> d (t,t+15);
int number = count_if(d.begin(), d.end(), Compare());
cout<< number<<endl;
return 0;
}

Program outputs:

  1. 12
  2. 4
  3. 2
  4. 0
  5. compilation error

Answer(s): E



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 <iostream>
#include "class.h"
using namespace std;

int main()
{
A<int> a;
cout << a.getV() << endl;
return 0;
}

//File: class.h
#ifndef _CLASS_
#define _CLASS_
template <class T>
class A {
T _v;
public:
A() {}
A(T v);
T getV();
};
#endif

//File: class.cpp
#include "class.h"

template<typename T>
A<T>::A(T v):_v(v) {}

template<class T>
T A<T>::getV() { return _v; }

  1. program will display: 0
  2. program will not compile
  3. program will display unpredictable number
  4. program willl be not linked

Answer(s): D



Page 16 of 58



Post your Comments and Discuss C++ Institute CPP exam with other Community members:

Nigel commented on September 27, 2024
Managed to pass my exam bu using the full version of this exam. This free version has less questions compared to PDF.
Spain
upvote

Kangaroo Jack commented on September 27, 2024
The best way to study and pass your exam. Quick and painless. The full PDF version is well worth the money.
AUSTRALIA
upvote

Ouahid commented on September 27, 2024
Thank you, it is very useful
AUSTRIA
upvote

Karlik commented on September 27, 2024
I passed the exam with help from this questions :)
Anonymous
upvote

Nate commented on September 27, 2024
Has anyone recently taken the exam? Can anyone confirm these questions are similar or word for word?
Anonymous
upvote

Birkha commented on September 27, 2024
NO comments
BHUTAN
upvote

raba commented on September 26, 2024
@khorshal can i use this alone to pass the exams
Anonymous
upvote

raba commented on September 26, 2024
some of the questions are straight forward
Anonymous
upvote

Judwa commented on September 26, 2024
This exam is super hard. I was overwhelmed. After using this exam dump, I went into the exam feeling a bit better. I passed my test. :-)
INDIA
upvote

Jubran commented on September 26, 2024
Clear explanations and well-structured content made it so much easier to prepare and pass.
UNITED STATES
upvote

KXK commented on September 26, 2024
The study guide was concise yet comprehensive. It helped me focus on the key topics and feel more prepared than ever!
INDIA
upvote

Chandra commented on September 26, 2024
I passed my exam with ease, thanks to the targeted material in this guide. It made a huge difference in how I prepared.
CANADA
upvote

raba commented on September 26, 2024
I was thinking question 16 should be a legacy systems
Anonymous
upvote

Bubba commented on September 26, 2024
Good work guys. The layout is user-friendly, and the content is spot on.
Hong Kong
upvote

rabihu commented on September 26, 2024
These are really challenging questions.i love it
Anonymous
upvote

Murad commented on September 26, 2024
This guide gave me the exact focus I needed to pass my exam on the first try. Highly effective and reliable.
Turkey
upvote

raba commented on September 26, 2024
these are really good questions
Anonymous
upvote

Kg commented on September 26, 2024
hi @phil , thank you for the response , basically i must just check wether the answers are correct
Anonymous
upvote

Alhassan commented on September 26, 2024
these are really good questions
Anonymous
upvote

Jose commented on September 26, 2024
these are really good questions
Anonymous
upvote

David commented on September 26, 2024
good Questions
Anonymous
upvote

Mohammed commented on September 26, 2024
Absolutely grateful for this exam dumps. Passed on the first set down.
France
upvote

Phil commented on September 26, 2024
Hi @kg I feel you. Based on my experience, the questions are valid but some of the answers were not accurate. So I managed to study and kinda figure these answers. For me the accuracy of the questions were more important and I saw most of them in the exam.
Anonymous
upvote

Madhan commented on September 26, 2024
Useful questions
INDIA
upvote

Owol Sentmi commented on September 26, 2024
great Questions
Anonymous
upvote

Noha commented on September 26, 2024
Feeling very confident now. Went over the free questions here then decided to buy the full PDF and test engine with the sale price and now ready to write my test. Will share my experience next week after I go for my exam. Wish me luck guys.
UNITED STATES
upvote

Baylis commented on September 26, 2024
I am certified now. Thank you team.
UNITED STATES
upvote

Harper commented on September 26, 2024
If you have access to full version of this exam dumps then you are good to go and pass your exam.
EUROPEAN UNION
upvote

Suil commented on September 26, 2024
Very good Practice questions
CHINA
upvote

lala commented on September 26, 2024
really helping
Anonymous
upvote

Champ commented on September 26, 2024
Good to see that something is still free. I truly appreciate this service.
Mexico
upvote

kg commented on September 26, 2024
anyone who sees this comment please respond to my question, can the answers on freedumps be trusted , because im using different materials also from exam topics and the answers dont look the same
Anonymous
upvote

Shams commented on September 25, 2024
This exam is valid in UAE. I passed.
UNITED ARAB EMIRATES
upvote

rb commented on September 25, 2024
these are really good questions
Anonymous
upvote