Pointers may be a confusing subject but I would not suggest that they are irrelevant or pointless (pun intended).
The abstraction being made with pointers allows elegant solution methods to tough problems. Skipping pointers is like skipping calculus because algebra has always been good enough. You leave a wide range of problems behind.
Besides, how else to take advantage of encapsulation and virtual functions?
Example: In a video game, a number of ships of several different class types move on a variety of path types. All ships are derived from an abstract base ship class, likewise for the paths.
Using pointers to arrays of pointers to the abstract classes involved I can write my game logic as:
1 2 3 4 5 6 7 8 9
|
for( int j= 0; j< Npaths; j++)
if( ppPath[j]->inUse )
for( int k= 0; k< ppPath[j]->Nships; k++)
if( ppPath[j]->ppShip[k]->inPlay )
{
ppPath[j]->move(k);
ppPath[j]->ppShip[k]->hittest();
ppPath[j]->ppShip[k]->draw();// maybe this goes in separate render loop
}
|
Where move() is virtual in the path classes and hittest() and draw() are virtual in the ship classes.
How else can this be done?
Also, hello to teapotz, 27f part time model.
EDIT: Forgot to mention that above pointers are also being used for the important task of handling the dynamic allocation and deletion of paths and ships as they come into, and go out of, play. Pointers are NEEDED for use with 'new' and 'delete' aren't they?