pointers

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
XxWalKaxX
Posts: 244
Joined: June 11th, 2012, 7:15 pm

pointers

Post by XxWalKaxX » June 28th, 2012, 2:10 am

ok ive watched the lessons on pointers a couple times and i understand about they work as far as pointing to particular address in mem. im just get confused when it comes to actually using them
What you call a bug...I call a new feature!

User avatar
codinitup
Posts: 112
Joined: June 27th, 2012, 7:43 am

Re: pointers

Post by codinitup » June 28th, 2012, 2:23 am

I would recommend that the best solution is to watch the videos again until you get pointers, or you can go to this website "Learncpp.com" and look to chapter 6, which looks at pointers directly. However I must say that it teaches pointers in a console project, maybe you can look at what the pointers do and then transfer the concept over to the graphical interface. The concept will remain the same, the only difference is the application of how it is used.
MOOOOOO

User avatar
npissoawsome
Posts: 114
Joined: June 8th, 2012, 3:01 pm

Re: pointers

Post by npissoawsome » June 28th, 2012, 4:51 am

XxWalKaxX wrote:ok ive watched the lessons on pointers a couple times and i understand about they work as far as pointing to particular address in mem. im just get confused when it comes to actually using them
well if I wanted to change the number of 3 vars I could write a function called

Code: Select all

void ChangeVar(*v1, *v2, *v3, num)
{
     *v1 = num;
     *v2 = num;
     *v3 = num;
}
than I could have some code

Code: Select all

int num1 = 0;
int num2 = 5;
int num3 = 3;
ChangeVar(&num1, &num2, &num3, 9);
cout << "Numbers are \nnum1: " << num1 << "\nnum2: " << num2 << "\nnum3: " << num3 << endl;
the output would be

Code: Select all

Numbers are
num1: 9
num2: 9
num3: 9
now this is a useless example, but it shows what they can be used for

Post Reply