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

Pages: 1-

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-06 18:40

Read your fucking book.

(*structure).member
is equivalent to
structure->member

Name: Anonymous 2012-03-06 19:07

Its called the pointy operator and it sends the value of a to b.

Ex. a->b is equivalent to b=a.

Name: Anonymous 2012-03-06 19:57

>>3

Name: Anonymous 2012-03-06 20:14

It's the tab stop operator. Fags use it instead of indenting their code.
if autism:
->print "fuck off, " + faggotquotify("faggot")
else:
->print "/polecat kebabs/"

Name: Anonymous 2012-03-06 20:34

It's the "definitely greater than" operator.

a>b*1000 can be rewritten as a->b.

Name: Anonymous 2012-03-06 20:57

Don't listen to the trolls, it's the "decrementing greater than comparison", or "dgtc" operator, it basically works like a -= b except that a -> b returns the comparison between a > b after assigning a to a - b.

Name: Anonymous 2012-03-06 22:11

It's supposed to simplify pointer arithmetic when using structures.
a->b;
is the same as
*(a.(void*)*(&a + (&b - &a)));

If you have several nested structures (a la 'a->b->c->d->e;`), then you can see how much simpler it looks using -> notation than it does using pure pointer notation.

Name: Anonymous 2012-03-06 22:38

>>8

I wished so much yours was true, I tried, but doesn't work. The thing after the '.' in *(a. fucks it up, expects a different token.

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;

}

Name: Anonymous 2012-03-07 1:31

>>10
And what if it is a class?

Name: Anonymous 2012-03-07 1:38

There is no telling what the arrow operator does, since it may be overloaded, so it can do basically anything.

Name: Anonymous 2012-03-07 1:41

>>12
C++ is a piece of shit. It gives the programmer just enough rope to castrate themselves. Learn C instead.

Name: Anonymous 2012-03-07 1:48

>>11 It is still the same thing.

Name: Anonymous 2012-03-07 1:49

>>12
This is the real answer to OPs question.

Name: >>14 2012-03-07 2:01

I never could have imagined that seeples would let you override the -> operator. What the fuck man, it doesn't even make sense! Why would you ever need p->x(a, b, c) to not be the same thing as (*p).x(a, b, c)?

Name: Anonymous 2012-03-07 2:18

>>16
It makes sense for smart pointers. Overloaded -> means a member of the object pointed to by the smart pointer, but . means a member of the smart pointer itself.

Name: Anonymous 2012-03-07 2:48

>>17
but that is taken care of if a->b always means (*a).b, which would get its meaning in this case by simply overloading the * dereference operator. Or is that how it works?

Name: Anonymous 2012-03-07 3:07

Name: Anonymous 2012-03-07 9:07

>>10

What I am saying is, I made a struct with a member called b, then I created one of it on the heap.

Then I tried to use *(a.(void*)*(&a + (&b - &a))); but it won't compile.

Name: Anonymous 2012-03-07 9:30

>>1
Don't let those previous posts fool you, >>1; It's shorthand for the goto operator! Program control is passed, after the left hand side is evaluated, to the label specified by right hand side of the expression. Example usage:

a -> b;

is like writing


a;
goto b;


where b is some arbitrary label in your program.

Name: Anonymous 2012-03-07 10:57





   a
    \
  b ->  d; // assigns value of d to a, b and c
    /
   c

Name: Anonymous 2012-03-07 11:54

>>22
No, that's the <- operator. -> would assign the values of a, b, and c to d.

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