Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 109,491 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,189 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



while loop

 
Reply to this topicStart new topic

while loop, "->"

raedbenz
post 2 Jul, 2008 - 10:42 PM
Post #1


New D.I.C Head

*
Joined: 13 Dec, 2006
Posts: 19


My Contributions


HI,,
i have seen some prgorams use in the while loop this condition "->" , instead of "=>" .
what "->" does mean?
thanks
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 2 Jul, 2008 - 10:50 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,942



Thanked 27 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


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.
User is online!Profile CardPM

Go to the top of the page

Einherjar
post 2 Jul, 2008 - 10:53 PM
Post #3


D.I.C Head

**
Joined: 10 Feb, 2008
Posts: 73


My Contributions


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:
CODE

while(somepointer->getValue())


This post has been edited by Einherjar: 2 Jul, 2008 - 10:53 PM
User is offlineProfile CardPM

Go to the top of the page

tortillaboy05
post 2 Jul, 2008 - 11:15 PM
Post #4


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 20


My Contributions


Yeah thats what I was thinking too. Its all the -> operator is used for as far as I know.
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 3 Jul, 2008 - 02:39 AM
Post #5


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,618



Thanked 51 times

Dream Kudos: 1550

Expert In: (X)HTML, CSS, Batch Scripting, C, C++

My Contributions


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 smile.gif

This post has been edited by gabehabe: 3 Jul, 2008 - 02:41 AM
User is online!Profile CardPM

Go to the top of the page

kapax
post 3 Jul, 2008 - 07:30 AM
Post #6


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 38



Thanked 1 times
My Contributions


Excuse me, but what is => ?

Is it the same as >= ?
User is offlineProfile CardPM

Go to the top of the page

Einherjar
post 3 Jul, 2008 - 12:37 PM
Post #7


D.I.C Head

**
Joined: 10 Feb, 2008
Posts: 73


My Contributions


QUOTE(kapax @ 3 Jul, 2008 - 10:30 AM) *

Excuse me, but what is => ?

Is it the same as >= ?


Well in C++ => doesn't exist, but it does in Ruby smile.gif
User is offlineProfile CardPM

Go to the top of the page

polymath
post 3 Jul, 2008 - 01:42 PM
Post #8


D.I.C Regular

Group Icon
Joined: 4 Apr, 2008
Posts: 390



Thanked 4 times

Dream Kudos: 500
My Contributions


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

Example:
cpp

struct thisStruct{
bool value;
int trash;
}

thisStruct * Object;
while (Object->value==true); // OR just while (Object->value);
User is offlineProfile CardPM

Go to the top of the page

ibaraku
post 3 Jul, 2008 - 01:52 PM
Post #9


D.I.C Head

**
Joined: 12 May, 2007
Posts: 137



Thanked 1 times
My Contributions


You could also like at it like so:
Let's say you have a struct or class called Record.
CODE

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
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 9/7/08 02:09PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month