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 are the syntactic rules to be avoid ambiguity in multiple inheritance?
What is #include sstream?
What is c++ hiding?
How much maximum can you allocate in a single call to malloc()?
Explain object slicing in c++?
Is there any function that can skip certain number of characters present in the input stream?
What is #include iostream?
What is heap sort in c++?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What is the use of typedef?
How to declare an array of pointers to integer?
Which operations are permitted on pointers?
What will the line of code below print out and why?
Can we distribute function templates and class templates in object libraries?
How do you remove an element from a set in c++?