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

C++ classes

Name: pieisgood 2008-02-06 18:50

I am just starting out programming. I want to make a calculator for all the questions I will be asked in my trig class, but I only want this on my computer so I could try to learn trig and programming sort of together.

That's not why I am here though. I am here because classes confuse the fuck out of me. I do not understand how to "think" in terms of classes. Dereferencing pointers to public blah blah blah. It's all very weird. I was wondering if you guys knew anything that could distill the idea of how to think of classes and how to write them.

Name: Anonymous 2008-02-06 18:56

A class describes the "owns" and "does" stuff of an object.
For instance, a duck "owns" internal organs, a beak, a pair of eyes, etc, and a duck "does" swim up and down an infinitely long river, quack, take a shit, find and eat food.


class Duck
{
Does:
    function quack();
    function shit();
    function swim();
Owns:
    internal_organs;
    beak;
    eyes;
}

The class simply describes these things. The point of using classes is to encapsulate such messy details like the organs, eyes, etc and expose only the operations we might be interested in, like quack and shit.

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