Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,893 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,769 people online right now. Registration is fast and FREE... Join Now!




while loop

 
Reply to this topicStart new topic

while loop, "->"

raedbenz
2 Jul, 2008 - 09: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
+Quote Post

no2pencil
RE: While Loop
2 Jul, 2008 - 09:50 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,494



Thanked: 66 times
Dream Kudos: 2425
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
+Quote Post

Einherjar
RE: While Loop
2 Jul, 2008 - 09: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 - 09:53 PM
User is offlineProfile CardPM
+Quote Post

tortillaboy05
RE: While Loop
2 Jul, 2008 - 10: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
+Quote Post

gabehabe
RE: While Loop
3 Jul, 2008 - 01:39 AM
Post #5

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,551



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

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 - 01:41 AM
User is offlineProfile CardPM
+Quote Post

kapax
RE: While Loop
3 Jul, 2008 - 06:30 AM
Post #6

New D.I.C Head
*

Joined: 2 Jul, 2008
Posts: 39



Thanked: 1 times
My Contributions
Excuse me, but what is => ?

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

Einherjar
RE: While Loop
3 Jul, 2008 - 11:37 AM
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
+Quote Post

polymath
RE: While Loop
3 Jul, 2008 - 12:42 PM
Post #8

D.I.C Regular
Group Icon

Joined: 4 Apr, 2008
Posts: 414



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
+Quote Post

ibaraku
RE: While Loop
3 Jul, 2008 - 12:52 PM
Post #9

D.I.C Head
Group Icon

Joined: 12 May, 2007
Posts: 164



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
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 09:15PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month