What is a class?

Answer Posted / abalonesoft

A class defines a data type, much like a struct would be in
C. In a computer science sense, a type consists of both a
set of states and a set of operations which transition
between those states. Thus int is a type because it has both
a set of states and it has operations like i + j or i++,
etc. In exactly the same way, a class provides a set of
(usually public) operations, and a set of (usually
non-public) data bits representing the abstract values that
instances of the type can have.

You can imagine that int is a class that has member
functions called operator++, etc. (int isn't really a class,
but the basic analogy is this: a class is a type, much like
int is a type.)

Note: a C programmer can think of a class as a C struct
whose members default to private. But if that's all you
think of a class, then you probably need to experience a
personal paradigm shift.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why main is used in c?

581


How do I swap bytes?

626


Explain the difference between structs and unions in c?

570


Why is c still so popular?

609


What is difference between structure and union?

593






What are compound statements?

622


What is the purpose of ftell?

595


what is the syallabus of computer science students in group- 1?

1832


What is strcpy() function?

652


What does %2f mean in c?

672


how to write a c program to print list of fruits in alpabetical order?

1784


What is derived datatype in c?

627


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

904


The difference between printf and fprintf is ?

714


Write a code of a general series where the next element is the sum of last k terms.

585