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
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
What does std mean in c++?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
What is the prototype of printf function?
When should I use unitbuf flag?
what is data abstraction in C++?
What do the keywords volatile and mean mutable?
What is the difference between a definition and a declaration?
Explain what are accessor methods?
How would you use qsort() function to sort an array of structures?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
what is C++ objects?
Why c++ is created?
What is the outcome of cout< a) 16 b) 17 c) 16.5
How we can differentiate between a pre and post increment operators during overloading?