Thursday, April 9, 2015

What is a class?

The fundamental building block of OO software.

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.

2 comments:

  1. Very nice post. I merely stumbled upon your journal and wished
    to mention that I even have extremely enjoyed browsing your weblog posts finally I’ll be subscribing on your feed and that I am hoping you write once more terribly soon!
    Our website

    ReplyDelete
  2. you will need support or suggestions, write me privately.
    I interested in your implementation/use case.
    the best situs slot terbaik
    Togel2win
    daftar bo bonanza
    Slot gampang menang

    ReplyDelete