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

A C++ question

Name: Anonymous 2012-03-06 18:28

What is the "->" operator in C++? And how to use the vector operator?

Name: Anonymous 2012-03-07 0:45

>>9
Well it really is to simplify pointer shit. It's not quite that much of a replacement, but it does substitute
a->b
for
(*a).b

For instance:

#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;

}

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