Deal of The Day! 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 8 Question 48 Discussion

What happens when you attempt to compile and run the following code?#include using namespace std;templatevoid g(int a){cout
B) program displays: 2
A) program displays: 1
C) compilation error
D) runtime exception

C++ Institute CPP Exam - Topic 8 Question 48 Discussion

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

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

#include

using namespace std;

template

void g(int a)

{

cout<

}

template

void g(A a)

{

cout<

}

int main()

{

int a = 1;

g(a);

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Geoffrey
7 months ago
Huh, I thought templates were more complicated than this!
upvoted 0 times
...
Monroe
7 months ago
Totally agree, it outputs 2!
upvoted 0 times
...
Scarlet
7 months ago
Wait, is there a compilation error here?
upvoted 0 times
...
Melynda
8 months ago
I think it should just print 1, right?
upvoted 0 times
...
Jettie
8 months ago
The second template will be called, so it prints 2.
upvoted 0 times
...
Lorean
8 months ago
This seems like a tricky one. I'm not sure if I should go with creating a new group in the LDAP directory or using a project role. Might need to think this through carefully.
upvoted 0 times
...
Desmond
8 months ago
Easy peasy! Install the unmanaged package, install the managed package, and make sure Chatter is enabled. The console view and contact-account settings are just extras.
upvoted 0 times
...

Save Cancel