What is the difference between Class and Structure?

Answer Posted / nikhil jain

Structures are value types; classes are reference types.
Structures use stack allocation; classes use heap
allocation.

A structure must have at least one nonshared variable or
event member; a
class can be completely empty.

Is This Answer Correct ?    4 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does std endl flush?

605


Explain shallow copy?

610


How to get the current position of the file pointer?

550


Is c++ a good beginners programming language?

580


Explain how the virtual base class is different from the conventional base classes of the opps.

677






Write about the members that a derived class can add?

564


How do you flush std cout?

560


How is new() different from malloc()?

622


What is setf in c++?

572


How would perform Pattern Matching in C++?

648


If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?

663


Write a struct time where integer m, h, s are its members?

513


What do you mean by “this” pointer?

613


Write a program to find the reverse Fibonacci series starting from N.

600


What is a template in c++?

633