title: Difference between Class and Structure in PHP and Java
body: <p>What is real difference between Class and Structure when you are dealing with Object Oriented Programming. This question is asked many times during my interviews for SE.</p>
  
  <p><strong>Some people says that there is only one difference:</strong>
  Structure members are public by default and Class members are private by default.</p>
  
  <p><strong>Some says there are many differences.</strong></p>
  
  <p><strong>After reading many articles and forums, I have the following differences:</strong></p>
  
  <p>Classes DEFAULT to having private members.  Structures DEFAULT to having public members.</p>
  
  <p>Structures are values type.
  Classes are reference type.</p>
  
  <p>Structure stores in memory via stack.
  Classes stored in memory via heap.</p>
  
  <p>Structure doesn’t support inheritance.
  Classes support inheritance.</p>
  
  <p>Constructor works in different way.</p>
  
  <p>‘new’ operator works in different way.</p>
  
  <p>Allocating memory for structure is very fast because this takes place inline or on the stack.</p>
  
  <p><strong>What are your opinion on my above list or you have a different one. Thanks</strong></p>