page 1 page 2
page 3 page 4 page 5 page 6 page 7 page 8
normal vulgar
now you've learned the basics, let's move on to some fun stuff (pointers are the
devil's minions, we'll try those later).
code:
#include <iostream>
int niggercount = 0;
class nigger
{
public:
nigger();
nigger(char*);
~nigger();
void steal(char*);
private:
char *niggername;
};
injected with racism to keep you paying attention, this is a perfect example of a class.
a class is your own object. it can have as many members inside as you want, and you
can make your own variable using this class, all those members belong to the variable now. this
will get tricky, so stay focused. a lot to learn. all the functions in this class are
prototypes, they have no body. they're being declared now, they will get a meaning
later.
public:
all the stuff below public is, well, public. anything public can be changed freely outside the
class, well you'll understand later.
nigger();
this is the class constructor. it's the function for when a nigger is
created (god forbid). right now, nothing happens.
nigger(char*);
this is a second constructor, in the case that the user makes a nigger with a char*
argument (this is essentially an array of char), this constructor will be the one to happen.
~nigger();
this is the destructor, it stands out because of the tilde in front of it. when a
nigger is destroyed (usually at a program's end), the destructor happens.
void
the type void is used generally for functions, ones that don't have a return value.
if you're not doing any math in the function or really dealing with numbers, void is a
safe pick.
private:
private members can only be changed by members of the same class. it won't make too much sense
right now, so skip it.
;
class declarations end with semicolons. good to know.
code:
nigger::nigger()
{
niggercount++;
}
nigger::nigger(char* name)
{
niggercount++;
niggername = name;
std::cout << "new nigger named " << niggername << " made!\n";
std::cout << "nigger population is currently: " << niggercount;
}
nigger::~nigger()
{
std::cout << "one less nigger in the world!";
}
void nigger::steal(char *obj)
{
std::cout << niggername << " will like his new " << obj << "!\n";
}
int main()
{
nigger blackman;
nigger blackman2("jerome");
blackman.steal("TV");
blackman2.steal("bike");
}
that's a ton of new stuff, so let's get going.
nigger::nigger()
it's better form to make the bodies of your class functions outside the class, it's even better
to do so in another file. but that can wait. to make a function outside the class, give the type
(if it's not a constructor or destructor) followed by classname::function(arguments). you
should recognize the double colon from the standard namespace, they are used in the same way.
nigger blackman; nigger blackman2("jerome");
here i demonstrate both constructors for niggers. the first one does nothing but create
a nigger and silently increase the running tab of them, the second one does the same
thing and tells us what it's doing and how many niggers there are.
blackman.steal("TV");
the new blackman object wasted no time getting to business, and immediately took a TV. let's
see what's actually happening. now that blackman has been created, you can access the nigger
members that it inherits with the . symbol, followed by the function or variable. in this code,
we get blackman to use the steal() function, and pass "TV" as an argument to it. the program
will inform us what blackman has just done, and then it's finished.
page 1 page 2
page 3 page 4
page 5 page 6 page 7 page 8