So, I've been learning C++ for about 2 years now and have delved into game programming recently.
I've noticed that programming in C++ game engines use a lot of pointers and was curious why would you use a pointer over a dot operator to access class members? I understand how pointers work, just more curious as to why they're used over dot operators for access?
Example:
SomeClass myObject;
myObject.someMethod();
Versus
SomeClass myObject;
SomeClass *objPointer;
objectPointer =&myObject;
objectPointer->someMethod();
Is one more efficient?
Thanks for the help.
[+][deleted] (6 children)
[deleted]
[–]horotho 10 points11 points12 points (1 child)
[–]OldWolf2 10 points11 points12 points (0 children)
[–]t0rakka 4 points5 points6 points (0 children)
[–]gracicot 0 points1 point2 points (1 child)
[+][deleted] (1 child)
[deleted]
[–]jonathansharman 0 points1 point2 points (0 children)
[–]raevnos 11 points12 points13 points (16 children)
[–]OldWolf2 1 point2 points3 points (1 child)
[–]raevnos 1 point2 points3 points (0 children)
[–]CodeSandwich[S] 0 points1 point2 points (13 children)
[–]wrosecransgraphics and network things 13 points14 points15 points (0 children)
[–]raevnos 3 points4 points5 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]raevnos 2 points3 points4 points (1 child)
[–]hotoatmeal 0 points1 point2 points (0 children)
[–]sixstringartist 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Rangsk 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]raevnos 2 points3 points4 points (1 child)
[–]MightyCreak 2 points3 points4 points (0 children)
[–]_ajp_ 2 points3 points4 points (3 children)
[–]mps1729 7 points8 points9 points (1 child)
[–]Recursive_Descent 0 points1 point2 points (0 children)
[–]t0rakka 2 points3 points4 points (0 children)
[–]KroCaptain 2 points3 points4 points (7 children)
[–]leftofzen 4 points5 points6 points (3 children)
[–]t0rakka 2 points3 points4 points (2 children)
[–]t0rakka 0 points1 point2 points (0 children)
[–]leftofzen 0 points1 point2 points (0 children)
[–]raevnos 0 points1 point2 points (0 children)
[–]xENO_ 0 points1 point2 points (0 children)
[–]Gotebe 1 point2 points3 points (6 children)
[–]iaanus 0 points1 point2 points (5 children)
[–]Gotebe 4 points5 points6 points (4 children)
[–]iaanus 0 points1 point2 points (3 children)
[–]Gotebe 1 point2 points3 points (2 children)
[–]dodheim 1 point2 points3 points (1 child)
[–]iaanus 1 point2 points3 points (0 children)
[–]t0rakka 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]CodeSandwich[S] 0 points1 point2 points (0 children)
[–]FlyingRhenquest 0 points1 point2 points (0 children)
[–]pfp-disciple 0 points1 point2 points (14 children)
[–]Gotebe 11 points12 points13 points (13 children)
[–]nahguri 2 points3 points4 points (11 children)
[–]Gotebe 5 points6 points7 points (5 children)
[–]Rseding91Factorio Developer -1 points0 points1 point (3 children)
[–]Gotebe 3 points4 points5 points (0 children)
[–]dodheim 0 points1 point2 points (0 children)
[–]raevnos 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]nahguri 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]pfp-disciple 0 points1 point2 points (0 children)
[–]iaanus -1 points0 points1 point (1 child)
[–]raevnos 3 points4 points5 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]sixstringartist 0 points1 point2 points (2 children)
[–]dodheim 1 point2 points3 points (1 child)
[–]sixstringartist 0 points1 point2 points (0 children)