Difference between "->" and "."
-
I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!
-
I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!
Nevermind, I found it in the documentation. Thanks anyway!
-
I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!
crushinghellhammer wrote: someclass.whatever CSomeClass myClass; myClass.whatever; crushinghellhammer wrote: someclass->whatever CSomeClass *myClass; myClass->whatever; The "." operator is used to directly access the object's members. Artificial intelligence is no match for natural stupidity.
-
I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!
-> dereferences a class object pointer. SomeClass { public : int a; }; So if you have SomeClass *oSomeClass = new oSomeClass(); Accessing member variable a is done by first dereferencing the pointer and using the '.'operator: (*oSomeClass).a = 5; which is equivalent to the statement oSomeClass->a = 5;