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
What is the best c++ compiler?
Show the declaration for a static function pointer.
What is array give example?
What are references in c++? What is a local reference?
Will this c++ program execute or not?
What do you mean by translation unit?
Do class declarations end with a semicolon?
Write a code/algo to find the frequency of each element in an array?
Is main a class in c++?
How can I learn dev c++ programming?
What is c++ stringstream?
What are associate containers?
What is the difference between a baller and a reference in C++?
You want to link a c++ program to c functions. How would you do it?
What is the difference between C and CPP?