CPP practice question 9 of 30
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; class A { int a; public: A(int…
Choose your answer, then check it against the explanation.
What happens when you attempt to compile and run the following code?
#include
#include
#include
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; }
operator int() const {return a;}
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
set s (t,t+15);
cout<<equal(s.begin(), s.end(), t)<<endl;
return 0;
}
Program outputs:
Question 9 of 30
Keep practicing
Take the free CPP practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CPP practice questions
- Question 1What happens when you attempt to compile and run the following code? #include #include #i…
- Question 2What happens when you attempt to compile and run the following code? #include #include #i…
- Question 3What happens when you attempt to compile and run the following code? #include #include us…
- Question 4What happens when you attempt to compile and run the following code? #include #include #i…
- Question 5What happens when you attempt to compile and run the following code? #include #include us…
- Question 6What will happen when you attempt to compile and run the code below, assuming that you en…
