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!
"ptrsomeclass->whatever" is shorthand for "(*ptrsomeclass).whatever" you must have a pointer to someclass to use -> you must have a direct instance of someclass to use . for example: someclass someobject; someclass* ptrobject = &someobject; //&=addressof someobject.whatever; (*ptrobject).whatever; //* dereferences address ptrobject->whatever; // same as line above Sincerely, -Ron