What is the importance of mutable keyword?
What is the default access level to a block of data?
What is the output of this program?
1. #include2. using namespace std; 3. struct X; 4. struct Y 5. { 6. void f(X*); 7. }; 8. struct X 9. { 10. private: 11. int i; 12. public: 13. void initialize(); 14. friend void g(X* , int); 15. friend void Y :: f(X*); 16. friend struct Z; 17. friend void h(); 18. }; 19. void X :: initialize() 20. { 21. i = 0; 22. } 23. void g(X* x, int i) 24. { 25. x -> i = i; 26. } 27. void Y :: f(X * x) 28. { 29. x -> i = 47; 30. cout << x->i; 31. } 32. struct Z 33. { 34. private: 35. int j; 36. public: 37. void initialize(); 38. void g(X* x); 39. }; 40. void Z::initialize() 41. { 42. j = 99; 43. } 44. void Z::g(X* x) 45. { 46. x -> i += j; 47. } 48. void h() 49. { 50. X x; 51. x.i = 100; 52. cout << x.i; 53. } 54. int main() 55. { 56. X x; 57. Z z; 58. z.g(&x); 59. cout << "Data accessed"; 60. }
What is the output of this program?
1. #include2. using namespace std; 3. class Cat 4. { 5. public: 6. int age; 7. int weight; 8. }; 9. int main() 10. { 11. Cat f; 12. f.age = 56; 13. cout << "Gates is " ; 14. cout << f.age << " years old.\n"; 15. }
What is the output of this program?
1. #include2. using namespace std; 3. struct A 4. { 5. private: 6. int i, j, k; 7. public: 8. int f(); 9. void g(); 10. }; 11. int A :: f() 12. { 13. return i + j + k; 14. } 15. void A :: g() 16. { 17. i = j = k = 0; 18. } 19. class B 20. { 21. int i, j, k; 22. public: 23. int f(); 24. void g(); 25. }; 26. int B :: f() 27. { 28. return i + j + k; 29. } 30. void B :: g() 31. { 32. i = j = k = 0; 33. } 34. int main() 35. { 36. A a; 37. B b; 38. a.f(); 39. a.g(); 40. b.f(); 41. b.g(); 42. cout << "Identical results would be produced"; 43. }