What is the difference between Class and Structure?

Answer Posted / anshu sharma

Structure are value types and classes are reference types.So
structures use stack and classes use heap.
Structures members can not be declared as protected , but
class members can be.
You can not do inheritance in structures.
Structures do not require constructors while classes require

Is This Answer Correct ?    158 Yes 54 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the decision making statements in C++? Explain if statement with an example?

634


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

538


Search for: what is pair in c++?

558


what is a class? Explain with an example.

591


Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h

630






How do I tokenize a string in c++?

585


How many characters are recognized by ANSI C++?

867


What is difference between class and structure in c++?

584


Explain linear search.

606


What is function declaration in c++ with example?

521


Why do we need templates?

522


Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

594


In what situations do you have to use initialization list rather than assignment in constructors?

606


What is #include iostream in c++?

563


What is the best c++ book for beginners?

552