Added: 3 years ago
From: thenewboston
Views: 82,030
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (200)

Sign In or Sign Up now to post a comment!
  • pointers are useful on returning variables to the main function as such

  • These tutorials are a cut above the rest available on youtube because you speak very clearly and you keep your video short, clean, and to the point. Keep up the great work and thanks!

  • Pointers are really difficult, and really I can't understand the reason of their existence. Man, if pointers are that difficult why does EVERYONE have them in "beginner" tutorials. This is intermediate to guru, not beginner...

  • @MrAlditho they are an essential part of programming because they allow you to manipulate variables without having to pass a whole bunch of copies to functons and returning them. All it is a variable that holds an adress of another variable once you wrap your head around it you will understand they take practice

  • the first one shows the value of finger, and the second one shows the address of finger

  • 1 question...when we did the thing as...int finger; cout<<finger<<endl; cout<<&finger<<endl; it showed me a code , and when we do it as int finger; int *pointer; pointer= &finger; cout<<pointer<<endl; it shows another code, why is that? thanks, btw. guide is epic! learned more like this than at class on colledge ;)

  • Address Operator just SHOWS where your data is stored and Pointers is a variable that HOLDS the adress in your memory ..

  • @ijustlovedogs13 this based on my understanding

  • thx bucky one of your example came in my ex same love you

  • I used to be a programmer like you, then I took a -> in the knee.

  • What i don't get is:

    cout << pointer;

    sure we could do this, or we could just do

    cout << &finger;

  • @Ezmbro Then, every time you use pointer, you dont have to type "&finger", just "pointer".

  • @Ezmbro what don't you get about those two statements?

  • i still dont get the point of the asterisk, wouldnt it do the same either way?

  • humor + learning = epic :D

  • explanation was crystal clear

  • Comment removed

  • sloppy code alert

  • you could just use: "cout << &finger;"

  • "so this will make a lot more sense when we use it to do something useful" LOL

  • why dont you use

    int finger=10,eyes=2;

    it kinda bugs me lol

  • @GameVidsxX Because its easier to understand/read that way.

  • watch /watch?v=Rxvv9krECNw if you still dont get it. It really helped me.

  • ia this similar to iterators

  • What is the point (no pun intended) of pointers? It seems you can do just as much without them.

  • @Mustang5Speed when you want to change an original variable from a function is the biggest use

  • @bondservant4Him Thanks, you answered my only question

  • lost a bit... why use pointers? can't I just say: "pointer = finger" instead of pointing to the address and then getting the value of finger?

    Just a bit confused

    thanks Great Tuts

  • @nfrancisj2122 creating pointers in c++ is just like using the ref our out type of parameter in c#, it is basically interacting directly with the variable instead of making copies...

  • @nfrancisj2122 although not exactly the same, it's just a comparison but don't get it as if they were the same...

  • what if you need a pointer for your pointer????

  • @Randude14 That's called a double pointer.

  • cool Teaching bro

  • You are awesome man. Finally a tutorial that actually helps

  • he calls it a star...

    DEAL WITH IT

  • pFont->DrawTextA(NULL, items[i], -1, &pRect, DT_NOCLIP, clr);

    for god's sake Bucky teach them some D3D =D

  • wtf mine is at the same adress

  • I can't understand why do we need the pointers?

  • @smurfy0706 yer aint it easierbto just write cout << "&finger" << endl;

    than to go and point to it

    my mum says its rude to point anyway

    do u lyk smurf vill or u just create a wacky cl name

  • @smurfy0706 Well, that seems to be the one thing no one seems to remember to explain - when you pass parameters to functions, the functions normally apply whatever they do to a copy of the input parameter, because FUCNTIONS cannot chanage their parameters, BUT if you use POINTERS instead of the actual thing your function can change what the pointer points to. Without pointer double(2) double(2) will return 4 both times, with pointers it will return 4 and 8 cuz the function "changed" the param

  • @smurfy0706 Note this explanation is not 100% accurate, but it is the best I can fit inside the comment limit. The whole idea is functions cannot change their parameters, thus if you use an object as a parameter, a different object is output, but if you use the adress or the pointer to that object, the program goes there and does its job on site instead of copying anything, the fixed parameter becomes the pointer, which allows the function to change the actual object that was passed as parameter

  • @smurfy0706 That is why if you pass the x=2 object as parameter, doubling x twice will return a copied 4 both times, where as if you pass the object with its pointer, the function will double x but instead of returning a copied result 4 it will actually change the value of x to 4, so that the next time double is ran on x, the value of x will get doubled to 8.

  • Dude you are awesome! This is the first vid of yours that I have seen and I already feel like I can really learn from you.

  • Imagine creating a coil by those spaces! That's engineering...

  • @mylifeis2coolcmc2

    of course,

    0 1 2 3 4 5 6 7 8 9 A B C D E F  |======| 4

    Its four bytes away.

    HexaDecimal means that you add up to 16 for each "10"

  • two ints 2 lines away yet it gives me

    001AF6FC for eyes and

    001AF708 for fingers!

  • hex: 22FF44

    dec: 2293572

    I used a calculator :3

  • learn c++ coding from this site pcfunia.com

  • @pcfunia BUCKYS BETTER YOU SUCK!

  • why did it jump from c to c++?

  • @Quphe c++ includes all the features of c plus additional features too

  • @Quphe .....*points to title of video*......

  • @Quphe it was always C++......

  • Good quality on your videos...

    Thats nice when you want to see the code.

  • Comment removed

  • i really appreciatiate ur tutorial thanks.

  • how fast can you say c++ five times!! great tutorial thanks

  • c++ tutorial???

  • you could just use: "int *pointer = &finger;"

  • @FrozenMasters that doesn't work because the memory address isn't an int try it.

  • @FrozenMasters that doesn't work because the memory address isn't an Intiger try it.

  • @Zeller002 it works as long as you declare finger as an int

  • @Zeller002

    If you can do

    int something = 10; Instead of

    int something;

    something = 10;

    why couldnt you do

    int *pointer = &finger; Instead of

    int *pointer;

    pointer = &finger;

  • @FrozenMasters you can do that

  • @FrozenMasters Actually you should allocate it first:

    int* pointer = 0;

    pointer = &finger;

  • @Jarzka1990 Meh i just had the conversation about this: If you can do int something = 10; Instead of int something; something = 10; why couldnt you do int *pointer = &finger; Instead of int *pointer; pointer = &finger;
  • dont understand the difference from using pointer and using &finger..

    for example cout << pointer shows the same exact thing as cout<<&finger.

    What's the point? (no pun intendeD)

  • @ObliviuxProductions Let's get this straight.

    int finger;

    "finger" is not a pointer, finger (as far as you're concerned) holds a direct value. More specifically, a 32 bit integer.

    int *pointer;

    "pointer" is a pointer :D. "pointer" holds an ADDRESS. This address points to a 32 bit integer. You can dereference that pointer to access the data stored as the address, using the dereference operator "*pointer".

    When you use the ampersand, you get the address of a variable.

  • @ObliviuxProductions

    further more.

    int *pointer;

    when you do not dereference a pointer (you refer to it by its name without using the * operator i.e "pointer"), you will get the its value, which will always be an address, as the pointer holds an address which points to a block of data in memory (an integer in this case).

    To help understanding, consider this.

    int *ptrMem = new int [256];

    ptrMem now points to 256, 4byte integers. So ptrMem holds an address of the beginning of that block.

  • @ObliviuxProductions So you can still use finger with the value of 10 and not the memory location.

  • Wait, declaring your point as int *pointer; is bad practice. It's better to declare the value null so it doesn't point to something random.

  • I'm gonna name my pointer,........pointer.......­.coz i am that creative.. LOL

  • @ChunFun1 i never understood why people that just script what a funny person says on a youtube video in their comment get the top rated comment almost all the time

  • Thanks for this, God bless

  • thanks Greg

  • great tutorials... but does it bug anyone else as much as me that it isn't indented and that last bracket is... OCD I can't help it.

  • You are so good, keep it up!

  • I watched your tutorials from the 1st tutorial -- and might I say -- the explanation is simple and sooooooo helpful! Thank you!!!

    And just an honest suggestion -- we could all do without the cockiness

    =)

  • @Zainub13 A tip on pointers.Pointers must be initialized when declared with a valid address or set it to null ( 0 ).A pointer unlike other varibles, allocates memory for an address ( 4 bytes on 32 machines and 8 on 64's ) not the type it points to! I might make tutorials with a little detail.If a pointer is not assign an address or 0, it will become a "wild" pointer( they are dangerous! ).

  • @BlackHeavenSymphony Good explanation, glad some one pointed this out!

  • @ZipArray It's almost a full year and i already know how to do templates! I got this good by reading a book( only 50$ ).I also study in great detail.I could do tutorials in detail, but i am not ready yet! But i recommend you get a book( you won't regret it ).

    Because online tutorials my not explain much detail.Pointers were basic for me so i could do things like polymorphism and memory control!

  • @BlackHeavenSymphony

    What book did you read?

  • @MrOsamaful "Sam's teach yourself C++"!

  • @BlackHeavenSymphony

    It seems that it's a very popular and good book. I think i may buy it :P Thx.

  • @BlackHeavenSymphony I have that book, I'm reading it now, but I dislike how it's organized. :\

  • @candychandelier It's better than some.But you will need another book called ivor horton's visual C++ 2010, if you want. It teaches you some stuff that's not in that one!

    Like "function pointers" and how to use visual studio 2010! It also teaches you how to make GUI's(Graphic User Interface)!

  • mine says 0x28ff44

    maybe cuz i'm 64 bit

  • this could not have been explained easier !!

  • Nice tutorial and very well explained.

  • Salam..Peace be upon you and your family...It is indeed the simplest and easiest way ...thanks bro n bless you.

  • why cant you just outpu &finger ??

  • @god4506 we're expanding and using pointers.

  • named mine "MoNkEyTwOtHiRtYThReE" because im THAT creative

  • ohh men your amazing....!!

    tnank you very much

  • excellent work dude, complete newb at programming and i feel like im leaps and bounds better after watching your first 16 videos you rock :)

  • Wow i think i got it.

    Ok so, the pointer is pointing to whatever value the 'finger' variable holds even if it changes value, is that right?

  • is c++ ur pet?? naomi??

  • Pointers in a nutshell: Pointers point to memory addresses

  • thanks ANXIOUS117

  • * is actually called a wildcard :)

  • whats the point of this tutorial of memory storage???

    im new to CS

  • @Poneivanfa well when you first start out programming you will probably be using a very high level language like VB, C# or Java but pointers are a more advanced subject of Computer Science with a pointer you can not only access a variables value with its memory address but you can also

  • @Poneivanfa request more memory from the free store and free up memory as well so you can access more memory at runtime instead of before execution an example of what you would use this for would be say if your making a game and you want to translate it to an eastern language western languages require 1 byte of information

  • @Poneivanfa per character to store data but most eastern languages require 2 so you would need to use pointers to access the free store to request more room for your data

  • hey does it mean if you change the value of 10 it will also mean that the hexadecimal number that was printed will also change?

  • @Testingpointer1 no that hexadecimal number is the variables memory address the only way it might change is if you free up the memory

  • @ANXIOUS117 so its like just the name of a container is that it?

  • @Testingpointer1 precisely and when I say free up the memory I mean using the delete and new keywords you can request more memory from the free store if your using the new keywork but you need to free up that memory before you can reassign a value which is what the delete keyword is for or you can unintentionaly cause a

  • @Testingpointer1 memory leak

  • @ANXIOUS117 so to be exact memory leak is is cause of adding a value to a memory that already have one? and that memory you are talking about is like an egg tray where in each slots(every slot is a memory) has named in hexadecimal code?

  • @Testingpointer1 a memory leak is when you can no longer access the value of a variable you declared because you forgot to free up the memory when you were done using it you can get unexpected results or your project can crash you will not be able to access that memory until execution of your project stops

  • @ANXIOUS117 yeah i get it now, thanks dude,

  • @Testingpointer1 yep no problem if you have any more questions regarding pointers just ask

  • It seems to like you like human and it´s anatomy.

  • the previous two vids were a bit blurry, but this one is great in 480

  • thenewboston - you rock man!

  • Why did u upgrade to vista! It sucks !!!!!! I love xp

  • @boringgirl123 You havent seen windows 7 then i guess :/

  • tutorial suppose to make it easy not confuse and this guy is superb

  • Whats the diffrence between:

    int

    double

    char

    can you please help me with that?

  • @MAGStation I will tell you: int can store numbers between: -2.147.148.648 and 2.147.148.648.

    double can store real numbers (2.3 , 45.54) that int cannot support

    char store's chars

    and long stores very long numbers between -10 billions and 10 billions

  • @ruscris2 actually short int stores between -32,767 and +32,767, int will store between -65,535 and +65,535 and long int will store between -2,147,483,647 and +2,147,483,647. char can store alphnumeric characters that includes a single letter, number, or certain symbols

  • @MAGStation int is whole numbers, in java, double is with decimals, it may be slightly different in C++ though, char is something to do with arguments and numbers or something like that i think :)

  • @TheMetalmaggot666 char is a byte of information or 8 bits. It's commonly used to represent ASCII characters as no characters goes above 127. An unsigned char can store from 0 - 255, a signed char can store negative numbers using the twos compliment, i.e -128 to 127

  • isn't this the same as the15:th tut?

  • I think the location of using namespace std does matter. For example:

    int main()

    {

    using namespace std;

    cout << "Standard Namespace";

    using namespace myTestNamespace;

    myTestNamespaceFunction();

    };

  • Comment removed

  • this is the most detailed series of c++ on youtube! 5 stars and i subscribed...keep going!

  • don't you normally put using namespace std outside main? Thats the way i learned it. probably doesnt make a differece

  • Comment removed

  • yea its the same, but someone told me its better to place it inside, but dont ask me why lol

  • @johnnyc130 If it is inside a function, then that namespace is local to that function. If it is outside of main, it is global.

  • how would you hook this into a process so you are searching for the values in another process on your computer?

  • I kinda like these tutorials better than XOAX's, even though his looks a little more professional, he speaks as though he's trying to teach someone who already knows another programming language, while thenewboston actually makes things clear to people without any experience (talking to us like we're stupid, if you will). It's easier to follow.

  • from the last tutorial I found out that boolean variables are the only variables that don't take up just 4 bytes, how is it possible?

  • Can you go:

    int *pointer = &finger;

    instead of:

    int *pointer;

    pointer = &finger;

    ?

  • yes..

  • @cbxsn

    yep

  • yes

  • yes

  • what is the point of using a pointer? :P

  • @nickrohn93 accessing memory within the free store thats when pointers really become usefull

  • @AXIOUS117 omg gilbert, anyway i know that now. at the time i always avoided * and &.  Although it is also helpful for garbage collection.

  • @nickrohn93 yep very true

  • @nickrohn93

    Primary use is for making data structures (try making a single linked list), all software have data structures; secondary the pointer data type is used as a data type with the API (i.e. gateway/"bag of functions") to devices through USB, Ethernet, Blue Tooth, etc.

  • @nickrohn93 to point something out....

  • best c++ tutorial giver i've found yet. everyone else sounds like such a plug, can't even listen to em. thanks man

  • So, why would you make a pointer, if you can just make a normal variable? :D

  • I had wondered that for a long time, here is what I came up with:

    int a=random_value, b=random_value;

    int *pointer=a+b;

    //now it doesn't matter if a or b change, "pointer" will always be equal to a+b

  • o ye 5 stars nice tut

  • dood use getchar(); not system("pause");

    much more efficient to use a function native to C instead of an OS specific function call

  • @dillon4321 Another thing is, OS specific function calls aren't portable. ;)

  • ye...that's why I said OS specific lol

  • lol you got an amazing site :D are you still working on it ? btw thanks a million times for the pointers tutorial :D !!

  • hey man thanks again for niceeeeee video , u're the best :D

  • So, when you quit the program, and start it up again.. Will it remember the variable?

  • no the variables are gone

  • No it does not i hope.

  • No, the variables and everything that you did in the program are lost, unless you save it to a file before closing the program.

  • this shit was annoyingly easy...

  • so was your mother

  • easy to understand, good tutorial

  • i get 0x22ff54. why is it different?

  • your's is in a different location that his is