C++ | Class and Object | Question 2

Predict the output of following C++ program

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(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



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.