Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Sepples

Name: Anonymous 2008-10-07 6:06

So can anybody tell me in a way one can understand it what a fucking class does?

Name: Anonymous 2008-10-07 6:13

It fucks.

Name: Anonymous 2008-10-07 6:16

Damn sepples programmers, can't even understand their own language, shoo! scat!

Name: Anonymous 2008-10-07 9:59

>>1
you sit in class to learn.

try paying attention next time and you might learn something.

Name: Anonymous 2008-10-07 11:03

I suggest that you read SICP, particularly the section on objects.

Name: Anonymous 2008-10-07 11:04

Better change majors to systems administration.

Name: Anonymous 2008-10-07 12:34

>>1
In OO software, "the fundamental building block".

A class is a type - a representation for a set of states (much like a C struct) and a set of operations for changing the state (moving from one state to another). Classes are similar to built-in types in this sense (for example, an int holds a bunch of bits and provides operations like + and *).

That's a correct theoretical definition. It's equally applicable to all OO languages, but they are different when it comes to more specific, practical aspects of their particular implementation of classes.

How do I create objects? And what happens when they are no longer needed? Is it my job to figure out which ones are unused and deallocate them? Bad.

What happens if I have bugs? If I have a pointer to an object, can it be invalid (be a random bit pattern, point to a dead object)? It can? The program will crash or worse? What about arrays of objects and out-of-bounds indexes? Crash or a modification of some other random object? You call that encapsulation? Bad.

What happens if I change/add/remove a private value, without changing the interface? All code using the class has to be recompiled? I bet you call that encapsulation, too. Bad.

What this really means, though, is that you, >>1, should stick with today's special.

Name: Anonymous 2008-10-07 14:51

>>7
So it's kind of like a monad?

Name: Anonymous 2008-10-07 15:00

>>8
More like a closure.

Name: Anonymous 2008-10-07 16:29

>>1,9
(defparameter *counter* (let ((count 0))
        (list
        #'(lambda () (incf count))
        #'(lambda () (decf count))
        #'(lambda () count))))

An OBJECT as a closure, minus dispatch.

Name: Anonymous 2008-10-07 17:28

A class is a blueprint for an object. An object is an instantiation of a class.
A class defines an objects state and behaviour.
State is defined through member variables, behaviour is defined via methods. Some of the big features touted by proponents of OO design are encapsulation and polymorphism. Encapsulation or information hiding'' is a way for an object to expose access to an object through its high level interface (ie. methods.) The advantage is whilst the methods stay the same, you can modify how things work at a lower level, so less code rewriting needs to be done.
Polymorphism is a technique for bringing together a bunch of different types of objects, but accessing them through a common set of methods. For example, Square, Triangle and Circle are all Shapes, so a program might use a Shape reference to access information about the shape, regardless of whether or not its a square or triangle or circle.

Name: Anonymous 2008-10-07 23:16

wat?

Name: Anonymous 2008-10-08 1:27

A class is a struct, but with functions inside of it as well as variables.  That's pretty much it.  You can put functions inside structs too.

The entire class forms a scope, so the functions in a class can access the variables in it.

Classes have a constructor (same name as the class) that's automatically called when you instantiate it, and a destructor (name of class with ~ in front of it) that's called when it's deallocated.  You can call any of a class's functions through the class (the functions of a class are often called methods).

Then there's copy constructors and operator overloading for double damage.  That's advanced, I can't help you with that.

Functions/variables in a class can be private, protected, or public.  Public stuff can be accessed outside the class, private/protected can't.  I forget what friends are, someone should say something about that.

Basically, a class's public functions become a front end for something you're trying to do.  Everything else remains private, that way other parts of the program can't fuck with it without going through your front end.  Until you realize that you still have to new and delete shit, don't even get me started on exceptions, and should just stick with C.

Name: Anonymous 2008-10-08 1:36

>>3-7,11,13
STOp BEING TROLT SO HARD YOU WORTHLESS FUCKS

Name: Anonymous 2008-10-08 9:01

EVERYTHING = EVERYTHING ELSE

COMPUTERS ARE A CLOSED CARTESIAN CATEGORY AND CO-CLOSED CARTESIAN CATEGORY, THREAD OVER.

Name: Anonymous 2008-10-08 10:31

I forget what friends are
so ronery ;_;

Name: Anonymous 2008-10-08 11:53

>>16
PROG QUALITY

Name: Anonymous 2008-10-08 12:21

>>17
PROG QUALITY

Name: Anonymous 2008-10-08 14:24

>>18
PROG QUALITY

Name: Anonymous 2008-10-08 16:01

>>17-19
back to /vip/, please

Name: Anonymous 2009-08-16 17:22

So phpfile PHP taking GET content

Name: ​​​​​​​​​​ 2010-10-26 12:33

Name: Anonymous 2011-02-04 16:30


Don't change these.
Name: Email:
Entire Thread Thread List