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

Who calls main function?

562


How do you write a function that can reverse a linked-list?

545


What are stacks? Give an example where they are useful.

564


Which programming language should I learn first?

556


What is a string example?

529






What are special characters c++?

542


Which programming language's unsatisfactory performance led to the discovery of c++?

771


What is a pointer how and when is it used?

553


What is the purpose of extern storage specifier?

594


Which is the best c++ compiler?

569


What is the rule of three?

550


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

528


What is the C-style character string?

581


What is #include cstdlib in c++?

628


Can I uninstall microsoft c++ redistributable?

580