Hello, I just started learning c++ and i don't see why you should use pointers.
For example, I have the following sourcecode:
char c = 'a';
char* p = &c;
char c2 = *p;
std::cout << c2;
this isn't useful is it? because you can also write :
char c = 'a';
std::cout << c;
and than you have the exact same outcome as the source with the pointer in it.
I heard that pointers save memory but i think there must be another reason to use them, I just don't know which reason.
Can someone please tell me the reason why to use pointers?
For example, I have the following sourcecode:
char c = 'a';
char* p = &c;
char c2 = *p;
std::cout << c2;
this isn't useful is it? because you can also write :
char c = 'a';
std::cout << c;
and than you have the exact same outcome as the source with the pointer in it.
I heard that pointers save memory but i think there must be another reason to use them, I just don't know which reason.
Can someone please tell me the reason why to use pointers?