What is the difference between Class and Structure?

Answer Posted / mohanraj.d

1.structure is a value type.but class is a reference type.
2.structure is stored in stack.but class is stored in heap.
3.struct cannot have default constructor.
4.struct do not support inheritance.
5.class can inherit from a class.
6.struct cannot have declare destructor.
7.class has define object and function.
8.structure has define only object.

Is This Answer Correct ?    50 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we define function inside main in c++?

561


When you overload member functions, in what ways must they differ?

599


How does c++ structure differ from c++ class?

598


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

656


What is the outcome of cout< a) 16 b) 17 c) 16.5

629






How do you traverse a btree in backward in-order?

631


what is upcasting in C++?

729


Does c++ support multilevel and multiple inheritances?

552


What is using namespace std in cpp?

557


What does iomanip mean in c++?

615


What is c++ used for in games?

613


How to give an alternate name to a namespace?

597


What is the best c++ compiler?

596


Is it possible to write a c++ template to check for a function's existence?

586


What is pure virtual function?

633