Difference between Class and Struct.
Answer Posted / naresh kukreti
The struct default access type is public. A struct should
typically be used for grouping data.
The class default access type is private, and the default
mode for inheritance is private. A class should be used for
grouping data and methods that operate on that data.
In short, the convention is to use struct when the purpose
is to group data, and use classes when we require data
abstraction and, perhaps inheritance.
In C++ structures and classes are passed by value, unless
explicitly de-referenced. In other languages classes and
structures may have distinct semantics - ie. objects
(instances of classes) may be passed by reference and
structures may be passed by value.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How will you write a code for accessing the length of an array without assigning it to another variable?
Explain why C language is procedural?
What is d scanf?
Do you know the purpose of 'register' keyword?
How can I get the current date or time of day in a c program?
What are global variables and how do you declare them?
How can I split up a string into whitespace-separated fields?
What is the -> in c?
Explain how do you determine the length of a string value that was stored in a variable?
Explain what does the format %10.2 mean when included in a printf statement?
Write a program to generate random numbers in c?
What is volatile variable how do you declare it?
What is unsigned int in c?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Why do we use int main instead of void main in c?