Hi,
What does the "*" does when placed after a type?
For example,
char* myvar;
Plus, anyone know of any good c++ reference sites?
Hi,
What does the "*" does when placed after a type?
For example,
char* myvar;
Plus, anyone know of any good c++ reference sites?
it is a pointer. it creates an object that points to another object. it has no real value.
What is the difference between:
chr* myvar
and
chr *myvar ...
there's no difference.....
compiler knows what you're doing in this case so it doesn't matter how u space out your code....
(pointer) is designed to hold a memeory address.
Regards,
matheo917
like he said theres really no point to it.. but just to tell you.. when you do
int *variable;
that declares a pointer like he said (it points to the memory address) now try this declare another variable and have it point to it.
int varone;
int *variable;
variable = &varone;
cout << variable;
take a look at what you get!
like they said, there isn't a difference, but there is one important fact you need to remember about where the * is placed: before the variable name of each pointer being defined.
char* x, y;
x will be a pointer, yet y will be just a char
if you wanted to create 2 pointers it would look like this
char* x, *y;
both x and y are now pointers of type char