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

What is the full form nasa?

597


Write a c program for binary addition of two 8 bit numbers.

3670


Can a program run without main?

636


Explain the operation of overloading of an assignment operator.

698


What is setf in c++?

584






What is constant in c++ with example?

616


Does dev c++ support c++ 11?

561


What is binary object model?

608


Is c++ the most powerful language?

573


Are strings mutable in c++?

698


Write about the members that a derived class can add?

572


What do you mean by inheritance in c++? Explain its types.

617


Can comments be nested?

632


Define whitespace in C++.

760


Is it possible to write a c++ template to check for a function's existence?

584