New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPP Exam - Topic 4 Question 47 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 47
Topic #: 4
[All CPP Questions]

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

#include

#include

using namespace std;

template

class A {

T_v;

public:

A() {}

A(T v): _v(v){}

T getV() { return _v; }

void add(T & a) { _v+=a; }

};

int main()

{

Aa("Hello");

string s(" world!");

a.add(s);

cout << a.getV() <

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
My
4 months ago
Definitely a compilation error, can't use T_v like that.
upvoted 0 times
...
Jin
4 months ago
Wait, really? I thought it would work fine!
upvoted 0 times
...
Lai
4 months ago
I thought it would just run and show "Hello world!"
upvoted 0 times
...
Sharen
4 months ago
Totally agree, it should be T _v; instead of T_v;
upvoted 0 times
...
Carlee
5 months ago
The program won't compile due to a typo in the template.
upvoted 0 times
...
Tammi
5 months ago
Hmm, I'm not totally sure about this one. I know a micrometer and caliper are contact measurement tools, but I'm not 100% confident on the laser scanner. I'll have to think this through carefully.
upvoted 0 times
...
Nakita
5 months ago
I feel pretty confident that the answer is C. The question is specifically about participants in the context of Analysis and Review, so it's likely referring to the unique email addresses and names that come up in the search results.
upvoted 0 times
...
Novella
5 months ago
I'm not completely sure, but I feel like I saw a question like this in practice where applying proven tech was emphasized.
upvoted 0 times
...

Save Cancel