Skip to content
Related Articles

Related Articles

C++ | Class and Object | Question 2
  • Last Updated : 05 Mar, 2013

Predict the output of following C++ program




#include<iostream>
using namespace std;
   
class Empty {};
   
int main()
{
  cout << sizeof(Empty);
  return 0;
}

(A) A non-zero value
(B) 0
(C) Compiler Error
(D) Runtime Error


Answer: (A)

Explanation: See Why is the size of an empty class not zero in C++

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :