Vidyalelo
C++ Programming · Q121

Classes and Objects in C++

Programming · C++ Programming · question 121

Q121

What will be the output of the following C++ code? #include using namespace std; const int SIZE = 10; class safe private: int arr[SIZE]; public: safe() register int i; for (i = 0; i SIZE) cout << "Index out of bounds" <<endl; return arr[0]; return arr[i]; ; int main() safe A; cout << A[5]; cout << A[12]; return 0;

A.
5Index out of bounds
0
Answer
B.
40
C.
50
D.
51

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board