Pointers are extremely important in c++..If you don't like them you can learn languages that handle pointers like in java...They arnt that complicated though...they just look intimidating because of the *..All they do is store the address of where a variable is located in ram...and you can access that variable's value by what is called de(reference)ing a pointer using a *...if its just a regular pointer *ptr.
You have to understand the context of when using the *..When declaring and when accessing the value stored at the pointer's memory location
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int x = 5;
int* ptr; // int* means declare a pointer of type int
// this is needed because the computer needs to know how big
// the dataType is going to be for the pointer
// int is 4 bytes
// double is 8
// string 24...ect
ptr = &x; // using the & (address of) operator here
//pass the memory location(address) of x into ptr
cout << ptr << endl; // output the memory location of x
cout << *ptr << endl; //dereference the pointer to x and output the value
//ptr = &x
//*ptr = x
Understanding them is both important and useful. The latest language version and standard library offer syntactic sugar that hides raw pointers, so you don't need to use as much pointers directly as you did with early C++.
For example:
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <algorithm>
#include <vector>
int main () {
std::vector<int> myints {3,7,2,5,6,4,9};
std::cout << "The smallest element is "
<< *std::min_element( std::begin(myints), std::end(myints) ) << '\n';
return 0;
}
Did that use pointers?
Apparently not. Iterators are (usually) more complex objects than plain pointers.
Seriously, were there no pointers, loops, ifs, etc in that program?
There most probably were, but they are all hidden in the library object implementations.
Have you heard about polymorphism and class hierarchies yet?
When you do, you will learn that pointers -- at least smart pointers -- are invaluable.