PDA

View Full Version : Pointers in C++



Boise
01-01-2016, 02:02 AM
Okay so in my C++ book I've gotten to the part about arrays, structures, unions, and then... pointers.
I'm having trouble understanding how pointers are assigned, and what assigning ways are illegal (like assigning and address to an int type?) So before I go to the section about new, could anyone help explain to me in simple terms how pointers work? (I've taught myself HTML and CSS, and JavaScript, but I haven't been practicing so I may have forgotten em. I can understand programming terms).

|ThyLuigi|
01-01-2016, 02:07 AM
http://stackoverflow.com/questions/7062853/c-pointer-assignment

Stackoverflow.com is generally a good place for programming questions.

Boise
01-01-2016, 02:17 AM
Thanks! That makes it easier to understand.

Boise
01-01-2016, 02:27 AM
Just one more thing. If we have 2 variables, int x, int *xx, with x = 24 and *xx = &x, how does *xx have the same value as x? I went on a compiler to see what each one prints out, and the results were

x =24
*xx=24
&x = (some huge hexadecimal value)

|ThyLuigi|
01-01-2016, 02:32 AM
Just one more thing. If we have 2 variables, int x, int *xx, with x = 24 and *xx = &x, how does *xx have the same value as x? I went on a compiler to see what each one prints out, and the results were

x =24
*xx=24
&x = (some huge hexadecimal value)

Well, what is the * in *xx? It could have something to do with it...sorry, the only language ik is Ruby.

Boise
01-01-2016, 02:35 AM
lol... * dignifies a pointer. I appreciate your help, but I think a person who knows C++ can help me more.

- - - Updated - - -

Btw, don't limit yourself to ruby. More languages you learn, the easier they are to pick up

|ThyLuigi|
01-01-2016, 02:36 AM
lol... * dignifies a pointer. I appreciate your help, but I think a person who knows C++ can help me more.

- - - Updated - - -

Btw, don't limit yourself to ruby. More languages you learn, the easier they are to pick up

I'm planning to learn more languages, next being Javascript.

Boise
01-01-2016, 02:45 AM
Just one more thing. If we have 2 variables, int x, int *xx, with x = 24 and *xx = &x, how does *xx have the same value as x? I went on a compiler to see what each one prints out, and the results were

x =24
*xx=24
&x = (some huge hexadecimal value)

I figured it out.
*xx is equal to x, and
xx (without pointer dignifier) is equal to &x


Thanks anyways

MyLegGuy
01-01-2016, 06:17 AM
Just a heads up, this game development forum is pretty much dead.
If you want better help, you should head elsewhere.

I think one guy here knows C++.
And I have not seen him post in ages.

Boise
01-01-2016, 06:30 AM
Lol I can tell. Well thanks.

|ThyLuigi|
01-01-2016, 06:32 AM
Lol I can tell. Well thanks.

I'd recommend that stack overflow website, it has millions of people answering questions about all kinds of programming languages.