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

How do you declare a set in c++?

528


Is oops and c++ same?

572


give me an example for testing a program showing the test path .show how the test is important and complex.

2417


What is the difference between equal to (==) and assignment operator (=)?

575


What do you mean by public protected and private in c++?

597






What is a virtual destructor? Explain the use of it?

541


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

586


Is nan a c++?

608


What is the difference between C and CPP?

624


Implement stack operations with pointers with appropriate exception checks.

562


what are the characteristics of Class Members in C++?

587


How can you link a c++ program to c functions?

617


Which is the best c++ software?

600


What is object in c++ example?

619


Is c or c++ more useful?

570