Noob programer

Discussion in 'Mac Programming' started by DanB91, Jul 2, 2007.

  1. macrumors 6502

    Joined:
    Jun 12, 2007
    Messages:
    258
    #1
    I am a very new programmer (age 15 :)) and i just started watching tutorials on C++. I can write a VERY simple program (simple calculator, but its ALOT of code) but there are a few concepts im trying to grasp but i just cant such as: pointers and classes. Can someone please clarify these 2 points for me?

    Thanx soo much

    I really want to become a programmer b/c i am sick of people not porting (or correctly porting) a program thats windows based for mac. I want to really aid in that situation.
     
  2. macrumors 68000

    Joined:
    Feb 23, 2006
    Messages:
    1,642
    #2
    About classes:

    http://en.wikipedia.org/wiki/Object-oriented_programming

    As you're reading through that, click on the links. The link about "software crisis" is important to understand why classes and OO programming exists.

    Don't worry about porting windows software to OS X right now. Work on building a strong foundation, learn about the history of programming. The "whys" are as important as the "hows"

    Any questions, feel free to contact me
     
  3. macrumors 68040

    MongoTheGeek

    Joined:
    Sep 13, 2003
    Messages:
    3,287
    Location:
    Its not so much where you are as when you are.
    #3
    Classes are a type. To use a concrete example, dog is a class. Your dog spot is an object. It is a physical thing. You dog belongs to the class dog. Dog implements certain methods that are particular to dogs such as piddle on the floor and bark. The dog class is a subclass of mammal. So it is a specialized mammal that knows how to bark and piddle on the floor, but it also implements all of the methods of mammal such as shed hair.

    A pointer is what it sounds like. Instead of being an object or a string or a number its just a pointer to where the number string or object is. Now there are a couple of reasons for it. The first is it saves time and memory because if you want to pass a large object around you don't have to give everyone their own copy. You can just tell them where yours is. The second reason is it allows them to work on and modify your copy.

    In C++ and object oriented programming it helps in obfuscation. You know that you are getting a pointer to an object of some class(or any of its subclasses) It doesn't matter to you what it is, what matters is that it has certain methods.
     
  4. macrumors 6502

    Joined:
    Jun 12, 2007
    Messages:
    258
    #4
    thanx ill just watch the tutorial another time and see if i can understand when to use pointers. sometimes they just whip out those asterisks for some reason, and either dont explain it, or explain it in a bad way.

    classes is a video ill have to watch 1000 times, ik it takes patience but thanx for the help!

    actually can anyone explain the point of private in a class? it just seems harder to get to and thats it

    thanx
     
  5. macrumors 68000

    Joined:
    Feb 23, 2006
    Messages:
    1,642
    #5
    The point of private variables is that you know that you'll never need them outside of that class, and that you really don't want outside influences playing with those variables.
     
  6. macrumors 6502

    Joined:
    Jun 12, 2007
    Messages:
    258
    #6
    thanx every one for their help. i really hope i can do C++ :) its so goddamn hard
     

Share This Page