What is the difference between Class and Structure?

Answer Posted / sundarchum

Structs are Value type. They are stored as a stack on
memory.
Class is reference type. They are stored as heap on memory.
Sturcts constructor must contain a parameter and cannot
have default constructor.
Class constructor may contain no parameter.
Struct cannot have instance field.
Class can have instance field.
Struct cannot inherit from a structure.
Class can inherit from a class.
Structs cannot declare a destructor.

Is This Answer Correct ?    101 Yes 49 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the syntactic rules to be avoid ambiguity in multiple inheritance?

625


What is #include sstream?

611


What is c++ hiding?

610


How much maximum can you allocate in a single call to malloc()?

625


Explain object slicing in c++?

578






Is there any function that can skip certain number of characters present in the input stream?

575


What is #include iostream?

727


What is heap sort in c++?

589


What is meant by entry controlled loop? What all C++ loops are exit controlled?

556


What is the use of typedef?

627


How to declare an array of pointers to integer?

572


Which operations are permitted on pointers?

557


What will the line of code below print out and why?

316


Can we distribute function templates and class templates in object libraries?

579


How do you remove an element from a set in c++?

568