I'm familiar with the concept of variables, and objects which store a specified type of data (or class). But what is a pointer? I need someone to perhaps break this down to me in a "literal" sense:
1. Where are they first declared?
Someone(posts I've read, across the internet) described this to me as being a memory address. And you read it using "&" sign and declare with "*"sign. I dont know what this means I'm continually confused on the subject And apparently if you want to write and work with alot of libs available in C++ you must know how to use and read and work with pointers. I just cannot figure it out since I've never worked with them and don't comprehend them. I can read their definition and totally draw a blank.
2. What are their limitations compared to just a variable?
or Field of data which a class holds. Perhaps I need to familiarize myself with some other type of data before jumping into this. Perhaps I am reading it all wrong, perhaps pointers are a value in a function you call from somewhere that point to a class's data and blaaaagh, my brain just shutdown a little, any help is appreciated.
1 2 3 4 5
|
//example
int main(int argc, *argv[])
{
return 0;
}
|
In this example, there is a pointer ... array? vector? I think its a vector. Not that I know the true difference, but someone told me that vectors are dynamic in size. Ehhh.
Anyway, its something the system provides apparently (according to an article I read, the int main function can be provided with these arguments which are built into your "system" whatever that means, is it something included in the operating system? a "kernel"?)
and anyway, I cant figure these out, I'm used to seeing variables being passed as parameters being stored inside of a class somewhere, whats the purpose of a pointer? in contrast?
Are they static? Are they a copy of a value held somewhere and you borrow it for some reason?
Any help is appreciated. I cant understand this and its very important because everywhere code is using pointers. Everywhere.