What is the difference between Class and Structure?
Answer Posted / p govind rao
1) structure :- In structure have a by default public.
In class have a by default private.
2) Structure cannot be inherited. But class can be
inherit.
3) There is no data hiding features comes with
structures. Classes do, private, protected and public.
4) A structure can't be abstract, a class can.
5) A structure is a value type, while a class is a
reference type.
6) A structure is contain only data member , but class
contain data member and member function.
7) In a Structure we can't initilse the value to the
variable but in class variable we assign the values.
8) Structure are value type, They are stored as a
stack on memory. where as class are reference type. They
are stored as heap on memory.
| Is This Answer Correct ? | 597 Yes | 96 No |
Post New Answer View All Answers
When are exception objects created?
Explain the difference between using macro and inline functions?
What does the ios::ate argument do?
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
What is a constant? Explain with an example.
Mention the ways in which parameterized can be invoked.
What is private public protected in c++?
Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.
Can we define function inside main in c++?
What is the purpose of ios::basefield in the following statement?
When must you use a pointer rather than a reference?
Do the parentheses after the type name make a difference with new?
Why do we use using namespace std in c++?
What is class in c++ with example?
What is singleton pattern in c++?