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 7 Question 34 Discussion

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

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

#include

#include

#include

using namespace std;

class A

{

int a;

public:

A(int a) {this?>a = a; c++;}

~A() { c??;}

static int c;

};

int A::c(0);

int main ()

{

A t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8 , 9};

vectorv1(t, t+10);

dequed1(v1.begin(), v1.end());

deque d2;

d2 = d1;

cout<

return 0;

}

How many objects of type A will be created:

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

0/2000 characters
Barrett
4 months ago
The static variable is a bit confusing, but I think 20 is right.
upvoted 0 times
...
Andra
4 months ago
Just 10 objects are created in the array.
upvoted 0 times
...
Lawrence
4 months ago
Wait, how can there be 40? That seems off.
upvoted 0 times
...
Devorah
4 months ago
I disagree, it's definitely 30!
upvoted 0 times
...
Eve
5 months ago
Looks like 20 objects will be created.
upvoted 0 times
...
Cassi
5 months ago
This looks like a straightforward question about the types of testing a test analyst should consider. I'll review the options carefully and choose the one that best fits the role and responsibilities of a test analyst.
upvoted 0 times
...
Donte
5 months ago
This looks straightforward. Since we're modifying the `finalMenu` array, which is a reference to `foodMenu1`, the changes should be reflected in `foodMenu1` as well. I'll go with option A.
upvoted 0 times
...

Save Cancel