What are the differences between a struct and a class in
C++?
Answer Posted / shivani
In Class Members are private by default.
In Structure Member are public by default.
structures are value typed where as classes are refernce
typed
Class can be inherited But Structure can't be inherited
In structures we cannot initilase the variable during the
declaration while in classes we can.
Structure s does not support polymorphism while class does
Structure can be declared without a tag at the first time,
but not in case of class.
e.g. struct { variables; }(struct variable list); [It would
not raise any error while comlitation]
class { access specifier: variable list; access specifier:
vari....
}; [it will cause an error while compilation]
| Is This Answer Correct ? | 3 Yes | 6 No |
Post New Answer View All Answers
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
To which numbering system can the binary number 1101100100111100 be easily converted to?
What is the best it certification?
Explain selection sorting?
What is an arraylist c++?
How is new() different from malloc()?
Explain the concept of friend function in c++?
Why use of template is better than a base class?
What is std :: flush?
What is c++ mutable?
What is c++ 11 and c++ 14?
Explain the concept of copy constructor?
What is the best c++ compiler?
What is the copy-and-swap idiom?
What are the extraction and insertion operators in c++?