Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For pointers and classes, here is my analogy. I'll use a deck of cards. The deck of cards has a face value and a type (9 of hearts, 4 of spades, etc.). So in our C++ like programming language of "Deck of Cards" we'll say the following:</p> <pre><code>HeartCard card = 4; // 4 of hearts! </code></pre> <p>Now, you know where the 4 of hearts is because by golly, you're holding the deck, face up in your hand, and it's at the top! So in relation to the rest of the cards, we'll just say the 4 of hearts is at BEGINNING. So, if I asked you what card is at BEGINNING, you would say, "The 4 of hearts of course!". Well, you just "pointed" me to where the card is. In our "Deck of Cards" programming language, you could just as well say the following:</p> <pre><code>HeartCard card = 4; // 4 of hearts! print &amp;card // the address is BEGINNING! </code></pre> <p>Now, turn your deck of cards over. The back side is now BEGINNING and you don't know what the card is. But, let's say you can make it whatever you want because you're full of magic. Let's do this in our "Deck of Cards" langauge!</p> <pre><code>HeartCard *pointerToCard = MakeMyCard( "10 of hearts" ); print pointerToCard // the value of this is BEGINNING! print *pointerToCard // this will be 10 of hearts! </code></pre> <p>Well, MakeMyCard( "10 of hearts" ) was you doing your magic and knowing that you wanted to point to BEGINNING, making the card a 10 of hearts! You turn your card over and, voila! Now, the * may throw you off. If so, check this out:</p> <pre><code>HeartCard *pointerToCard = MakeMyCard( "10 of hearts" ); HeartCard card = 4; // 4 of hearts! print *pointerToCard; // prints 10 of hearts print pointerToCard; // prints BEGINNING print card; // prints 4 of hearts print &amp;card; // prints END - the 4 of hearts used to be on top but we flipped over the deck! </code></pre> <p>As for classes, we've been using classes in the example by defining a type as HeartCard. We know what a HeartCard is... It's a card with a value and the type of heart! So, we've classified that as a HeartCard. Each language has a similar way of defining or "classifying" what you want, but they all share the same concept! Hope this helped...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload