cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Whats the difference between using -> an
Whats the difference between using -> and using . ?
Jan 8, 2019 at 1:25pm UTC
bretjoseph
(9)
In c++ you can do Class. and Class->. What are those, when are they used?
Jan 8, 2019 at 1:42pm UTC
coder777
(8444)
-> is used to reference members of the class when the instance of that class is a pointer.
. is used to directly access the members of the class. For non pointer objects.
Jan 8, 2019 at 2:24pm UTC
MikeyBoy
(5631)
Or, to put it another way:
a->b
is exactly the same as:
(*a).b
Jan 8, 2019 at 3:06pm UTC
ne555
(10692)
> In c++ you can do Class. and Class->.
not really
you may do object. or pointer->
or object-> if you overload the arrow operator
Jan 9, 2019 at 9:42am UTC
bretjoseph
(9)
Thanks all
Topic archived. No new replies allowed.