Advertisement

what does -> mean

Started by June 15, 2002 02:03 PM
6 comments, last by xiros 22 years, 8 months ago
I am trying to learn C++ and I understand most of it so far but have no idea what -> does. Example from tut 31: glTexCoord2f( pTri->m_s[k], pTri->m_t[k] );
That is pointer to structure member operator and it references struct/class/union field through a pointer. Basically, it''s the same thing as ''.'' for a class object.
---visit #directxdev on afternet <- not just for directx, despite the name
Advertisement
Normally you would write something like this:
myStruct.someVariable
When using a pointer you just change . to ->

------------
aud.vze.com - The Audacious Engine <-- It''s not much, yet. But it''s mine... my own... my preciousssss...
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
_______________________________________Pixelante Game Studios - Fowl Language
http://www.bruceeckel.com/ -> Thinking In C++

That''s a _free_ eBook. Download it, read it. Soon it will all become apparent.


Just to add :

The -> operator is used a short hand method of accessing members through pointers.


  myClass* myInstance = new myClass;// The following two lines do the same thingmyInstance->Function(); (*myInstance).Function();//same with datamembersmyInstance->datamember = 6; (*myInstance).datamember = 6;delete myInstance;  



It saves you from having to deref''ing the pointer first.


-------
Andrew



Is there any other free ebooks by bruce eckel other than Thinking in C++ 1 & 2.
Advertisement
Is there any other free ebooks by bruce eckel other than Thinking in C++ 1 & 2.
Yes - Thinking in Java, Thinking in Python, Thinking in C# and Thinking in Patterns.

--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement