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
If a function doesn’t return a value, how do you declare the function?
What is runtime polymorphism in c++?
Explain the difference between realloc() and free() in c++?
What is singleton pattern in c++?
How does java differ from c and c++?
What is the difference between global int and static int declaration?
How do you traverse a btree in backward in-order?
Why do we need constructors in c++?
Why we use #include iostream in c++?
What is constructor in C++?
What is a unnitialised pointer?
What do you understand by pure virtual function? Write about its use?
Explain the difference between static and dynamic binding of functions?
Can we get the value of ios format flags?
Give 10 points of differences between C & C++.