8 Replies - 587 Views - Last Post: 03 July 2008 - 01:52 PM Rate Topic: -----

#1 raedbenz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 13-December 06

while loop

Posted 02 July 2008 - 10:42 PM

HI,,
i have seen some prgorams use in the while loop this condition "->" , instead of "=>" .
what "->" does mean?
thanks
Is This A Good Question/Topic? 0
  • +

Replies To: while loop

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5234
  • View blog
  • Posts: 27,025
  • Joined: 10-May 07

Re: while loop

Posted 02 July 2008 - 10:50 PM

I don't think that I've ever seen that used. Can you post an example?

I'm pretty sure, feel free to correct me, but you can't use a minus sign in the conditional. It's either greater than, less than, or equal to. The only combination being the equal to can be combined with either of the less than or greater than.
Was This Post Helpful? 0
  • +
  • -

#3 Einherjar  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 10-February 08

Re: while loop

Posted 02 July 2008 - 10:53 PM

My guess is that they are checking some member function of a pointer in the conditional of the while loop. If that makes sense... In other words:
while(somepointer->getValue())


This post has been edited by Einherjar: 02 July 2008 - 10:53 PM

Was This Post Helpful? 0
  • +
  • -

#4 tortillaboy05  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-July 08

Re: while loop

Posted 02 July 2008 - 11:15 PM

Yeah thats what I was thinking too. Its all the -> operator is used for as far as I know.
Was This Post Helpful? 0
  • +
  • -

#5 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: while loop

Posted 03 July 2008 - 02:39 AM

It's used when you create a class pointer.

So, say you have a class SomeClass it would be created like:
SomeClass *p;

Then, instead of using . you would use -> like:
p->SomeFunction();

Another example is the this-> pointer, used in function definitions from within a class.

Hope this helps :)

This post has been edited by gabehabe: 03 July 2008 - 02:41 AM

Was This Post Helpful? 0
  • +
  • -

#6 kapax  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 65
  • Joined: 02-July 08

Re: while loop

Posted 03 July 2008 - 07:30 AM

Excuse me, but what is => ?

Is it the same as >= ?
Was This Post Helpful? 0
  • +
  • -

#7 Einherjar  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 10-February 08

Re: while loop

Posted 03 July 2008 - 12:37 PM

View Postkapax, on 3 Jul, 2008 - 10:30 AM, said:

Excuse me, but what is => ?

Is it the same as >= ?


Well in C++ => doesn't exist, but it does in Ruby :)
Was This Post Helpful? 0
  • +
  • -

#8 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: while loop

Posted 03 July 2008 - 01:42 PM

Well, the -> operator is also used for structures in C/C++.

Example:
struct thisStruct{
   bool value;
   int trash;
}

thisStruct * Object;
while (Object->value==true); // OR just while (Object->value);


Was This Post Helpful? 0
  • +
  • -

#9 ibaraku  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 12-May 07

Re: while loop

Posted 03 July 2008 - 01:52 PM

You could also like at it like so:
Let's say you have a struct or class called Record.
Record *p;
p = new Record;
p->grade = 'A';



The notation p->grade is the same as (*p).grade
sometimes seeing that helps understand what the arrow operator means
hope that helps
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1