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

What do you mean by static variables?

610


What are the 3 levels of programming languages?

546


How do I download c++?

577


Does dev c++ support c++ 11?

565


Who was the creator of c++?

571






What are the extraction and insertion operators in c++? Explain with examples.

661


What is meant by the term name mangling in c++?

526


What are the differences between java and c++?

540


What is the use of object in c++?

580


Write some differences between an external iterator and an internal iterator?

595


What are the stages in the development cycle?

585


What is c++ in english?

585


what does the following statement mean? int (*a)[4]

625


What are c++ variables?

542


Differentiate between the manipulator and setf( ) function?

602