Name: Anonymous 2012-03-06 18:28
What is the "->" operator in C++? And how to use the vector operator?
#define POST "Inane, asinine garbage"
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
typedef struct __shitpost
{
string kotehan; // NAME
string com; // COMMENT
}SHITPOST;
SHITPOST * GenerateShitpost();
void main()
{
SHITPOST * newShit = GenerateShitpost();
cout << newShit->com << endl << "by \t\t" << (*newShit).kotehan;
// ***************************************************************
// * Notice that newShit->com would do the same as (*newShit).com
// * A structure name is a pointer the the first memory address,
// * and the var after the . is the offset from that. This is
// * complicated if it is a pointer to a struct, leading to the
// * (*a).b notation. a->b is an attempt to mask that from the
// * common programmer.
// ***************************************************************
}
SHITPOST * GenerateShitpost()
{
SHITPOST * shit = new SHITPOST;
shit->com = POST;
shit->kotehan = "Anonymous";
return shit;
}