Difference between Class and Struct.

Answer Posted / jammu hari cell:9848278041

Difference between class & Structure is :-
-------------------------------------------

1. class = data + functions
structure=Collection of different data
2. Class supports Re-usability. Structures are used to handle
the complex data.
3. Both are user defined data types.
4. 'struct' is a keyword which is used to declare a structure.
'class' is a keyword used to declare a class.
5. By default all the structure members are public. But in
class all the members are private.
6. Structure variable is used to access the structure
members. Object is used to access the class members.
7. Structure is less secure than the class.
8. Structure is a procedure Oriented feature. Object is a
Object Oriented Feature.
9. Both Structure & Class uses (.) dot operator to access
their members.
10. class contains 3 access specifiers But structure has
only 1 access specifier.
11. We can inherit a class. But we can't inherit structure.
12. We can declare constructors & destructors inside of a
class. But we can't declare these in Structure.

Is This Answer Correct ?    20 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are compound statements?

605


writ a program to compare using strcmp VIVA and viva with its output.

1525


explain what is fifo?

633


Why c is a procedural language?

583


What is the purpose of main( ) in c language?

620






When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

588


Can a pointer be volatile in c?

535


Why c is called top down?

626


What is the scope of static variables in c language?

628


Where define directive used?

607


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1448


How do you list a file’s date and time?

634


What is string function in c?

540


How can I remove the trailing spaces from a string?

616


What is the use of a semicolon (;) at the end of every program statement?

774