What is the difference between Class and Structure?

Answer Posted / guest

(1)Class Design For Object , Struct Design For Value Thus
Class is Refrence Type (Heape) but Struct is Value Type
(Stack) And Thus Struct is Faster Than Class ,

(2) Class is not Accessable Meanning We Can Access it By
Object , Struct is Accessable Meanning We Can Access it By
Value (Varible).

(3) Class Support Inheritance , Struct Not Support Inheritance .

(4)Class id Added Behavior (Methods) , Struct Not Added
Behavior

(5)Class Exist at higher Level of the Program , Struct Exist
at Lowest Level of the Program .

(6) A struct cannot declare a default constructor (a
constructor without parameters) or a destructor.Class Can .

(7)a small class may be more efficiently handled by the
system if you declare it as a struct instead.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c++ is better than c?

514


What is a static member?

611


How can you tell what shell you are running on unix system?

639


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

552


What does it mean to declare a member variable as static?

612






What is the header file for setw?

573


What is endl?

631


What is oops in c++?

587


Eplain extern keyword?

560


What is cout flush?

568


Explain about templates of C++.

676


What are smart pointers?

668


What is the difference between public, private, and protected access?

616


When does a 'this' pointer get created?

616


What are the c++ access specifiers?

771