Thread: Learning C++

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    66

    Learning C++

    Alright couple questions out there for experienced and none experience alright. How long did it take you to get comfortable with c++ and understand a majority of it. I am up too Classes and Structures Pointers and References but I am not comfortable with any of them and don't really understand Classes. So if you could answer that would be great and also anyone in college taking any programming classes tell me about the college and the classes cause next year will be college for me and I need some good advice on schools. Thanks

    Ryan

  2. #2
    Unregistered
    Guest
    Think of classes as a category. For example, if you have class dog, you can declare dog James, dog Herman, or dog Bourne. Each one of these dogs will have all of the properties of a dog. In c++, this is the variables and methods inside the class. To access them, you would use the instance of the class, ie James, then use the . operator, then the variable name or method name. For example, to access the public variable age of dog James, you would type James.age. Then, when you want to restrict how variables are accessed, you would declare then private. This means to access them, one has to create an additional public method inside the class that simply returns the value of the variable. To read up on this, go to the following site: http://www.stud.fim.ntnu.no/~oystesk/CPP/htm/ch06.htm and continue reading the chapters to understand references and pointers.

  3. #3
    Unregistered
    Guest
    Think of classes as a VCR.....

    You provide the VCR with input (a tape) or in the case of your program user input.

    Now that the VCR has the input, you can access the information by pressing play on the VCR.

    Now then, do you know EXACTLY what happens inside your VCR whenever you press the play button??? Of course not! and why should you??? All you care about is that the picture appears and you can watch the movie.


    The same is true with classes.

    You can declare a VCR class. by declaring that you automatically know that a VCR comes with a play button, rewind button, etc.

    So, whenever you want to press play just call the member function of the class like so....


    VCR.play();


    The coolest thing about classes is that you don't have to know (unless you are writing the classes) what goes on behind the scenes.


    Another cool thing about classes is inheritance.

    Some VCRs are dual deck, so you can declare a class of VCR that has two tape decks. The only (ok, not technically, just humor me) thing that is different between a regular VCR and a dual deck
    is the extra deck....

    So, why write a whole new class?

    Just declare:

    public DualVCR :: VCR

    and then accomidate the changes.

    Hope this helps!

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    66
    Alright I am getting classes now. You use them to break something done into its components right? Like for a computer (a really simple computer like a terminal or something) the class would be

    class Computer
    {
    private:
    int dataincomputer; //cause you don't wanna anybody accessing your data
    public:
    int type(); //inputing data into computer
    int display(); //displaying data you input
    }

    int Computer::type()
    {
    //get keyboard input
    }

    so on and so forth is this right?????????

    Also I have been programming hard for about 2 months would this just be considered average learning or above average???

  5. #5
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    one advice

    I would really suggest you not to go on to another topic in C++ if you don't clearly understand the one before man. This can come back to haunt you later on, make sure you know how to do the topic FIRST and THEN move on.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  2. Best Approach for Learning
    By UCnLA in forum C Programming
    Replies: 5
    Last Post: 03-21-2008, 02:35 AM
  3. Need Help On a Simple Bank Program
    By oobootsy1 in forum C# Programming
    Replies: 9
    Last Post: 08-08-2005, 10:51 AM
  4. Fun Learning a New Language
    By UnregdRegd in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-30-2003, 10:03 PM
  5. Learning Rate Of C++
    By Krak in forum C++ Programming
    Replies: 27
    Last Post: 01-29-2003, 01:53 PM