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

How to implement is-a and has-a class relationships?

578


Explain the uses of static class data?

591


Write a program to find the Factorial of a number

563


Why is c++ still best?

547


What is token c++?

574






What are libraries in c++?

601


Differentiate between C and C++.

703


How are Structure passing and returning implemented by the compiler?

593


What does return 0 do in c++?

574


What is copy constructor? Can we make copy constructor private in c++?

589


How many keywords are used in c++?

552


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

629


What are structures and unions?

565


What is expression parser in c++

1884


What is the function to call to turn an ascii string into a long?

592