GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 23 of 203    Print  
What is the difference between structures and classes in C++?
There is only one difference ,in classes the members are private by default whereas it is not so in structures.



  
Total Answers and Comments: 8 Last Update: January 05, 2009   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 21, 2005 14:07:24   #1  
kiranmayijosyula Member Since: October 2005   Contribution: 7    

RE: What is the difference between structures and clas...
structure member are public in default and class members are private in default.

 
Is this answer useful? Yes | No
December 09, 2005 11:13:38   #2  
sahu Member Since: December 2005   Contribution: 323    

RE: What is the difference between structures and clas...

difference between structures and clas...

Ans:

Structs are value-type variables and are thus saved on the stack additional overhead but faster retrieval. Another difference is that structs cannot inherit.


 
Is this answer useful? Yes | No
April 02, 2007 07:54:48   #3  
Dinesh Taparia        

RE: What is the difference between structures and clas...
U can inherit structure. And the default inheritence is public whereas in class the default inheritence is private
 
Is this answer useful? Yes | No
May 21, 2007 23:01:36   #4  
heyjoe Member Since: May 2007   Contribution: 2    

RE: What is the difference between structures and clas...
There is only one difference between struct & class in 'C++'.. All the variables/functions in struct are 'public' and in class they are 'private' by default. This is a very common misconception even among experienced Software engineers.
 
Is this answer useful? Yes | No
August 20, 2007 08:26:37   #5  
MAYUR BHAYANI        

RE: What is the difference between structures and clas...

There is not just a one difference. Differences are many like
The structure are uses stack and class uses heap memory.
The structure cannot use pointers while class can.
The strucure may not have private.
You can not define object of structure while you can define object of class.
Class is a blue print while structure is actual data.

Mayur Bhayani


 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
October 26, 2007 05:35:18   #6  
Amit Gupta        

RE: What is the difference between structures and clas...

class does not occupy any memory until we are not going to define any object for that class.
In other way class are the blue print and object are the real time entity or instance of the class which is occupying the memory.

Class are other features like abstraction encapsulation polymorphism which are not implemented by structure.


 
Is this answer useful? Yes | No
December 01, 2007 18:07:06   #7  
berezleon Member Since: December 2007   Contribution: 6    

RE: What is the difference between structures and classes in C++?
Amid you are talking about "C" structure that knows nothing about classes etc. The only difference between C++ class and struct is default access specifier (private and public respectively)
 
Is this answer useful? Yes | No
January 05, 2009 08:31:57   #8  
sripudi Member Since: October 2008   Contribution: 1    

RE: What is the difference between structures and classes in C++?
There are a lot of differences between Structure & Class in C.
But in C++ the only difference is the members structure are by default public where as class members are by default private.
Using C++ structure we can do the OOPS concepts like inheritance

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape