What is the difference between struct and class?

Answer Posted / hrpynux@gmail.com

Structs are value type whereas Classes are reference type. Structs are stored on the stack whereas Classes are stored on the heap. Value types hold their value in memory where they are declared, but reference type holds a reference to an object memory.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we use #include iostream in c++?

766


Is there finally in c++?

811


Explain what are single and multiple inheritances in c++?

730


Is set c++?

749


Can non graphic characters be used and processed in C++?

900


What is an object in c++?

814


What is an undefined reference/unresolved external symbol error and how do I fix it?

827


What are the main features of c++?

743


What is stl containers in c++?

768


What are the uses of static class data?

859


How can we check whether the contents of two structure variables are same or not?

807


What is void pointer in c++ with example?

792


Explain register storage specifier.

776


Which is the best c++ compiler for beginners?

777


What is this pointer in c++?

1007