What is the difference between Class and Structure?

Answer Posted / p govind rao

1) structure :- In structure have a by default public.
In class have a by default private.
2) Structure cannot be inherited. But class can be
inherit.
3) There is no data hiding features comes with
structures. Classes do, private, protected and public.
4) A structure can't be abstract, a class can.
5) A structure is a value type, while a class is a
reference type.
6) A structure is contain only data member , but class
contain data member and member function.
7) In a Structure we can't initilse the value to the
variable but in class variable we assign the values.
8) Structure are value type, They are stored as a
stack on memory. where as class are reference type. They
are stored as heap on memory.

Is This Answer Correct ?    597 Yes 96 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why use of template is better than a base class?

633


What is a down cast?

596


Is swift faster than c++?

551


Explain friend class?

616


Write about all the implicit member functions of a class?

588






Explain the scope of resolution operator.

621


What is data types c++?

534


What do c++ programmers do?

545


What is the use of :: operator in c++?

586


What is the best c++ ide?

589


What does the linker do?

582


What is an associative container in c++?

539


List the issue that the auto_ptr object handles?

597


What is std :: endl?

586


Using a smart pointer can we iterate through a container?

550