Thread: Ok so I now know how to do...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    20

    Ok so I now know how to do...

    The hello world and the tab like cout << "The sum of 2 + 2 is:\t" << 4 << endl;.........What should I learn now? btw I can't wait to start college for CS in july
    Last edited by PCG33K; 10-03-2007 at 11:56 AM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >What should I learn now?
    Your mastery of C++ is astounding! To be honest, there's nothing left to learn, so you can go ahead and write an OS or a compiler, or the next blockbuster game.

    But seriously, try learning the myriad ways of getting input with C++. That should give you a very strong foundation in input streams.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    20
    Ok will do yay ......also, I am now actually understanding what tutorials and ebooks for C++ are talking about which is what makes me excited.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Not much is more exciting than that "Aha!" moment. Be careful, because it's very addictive.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    20
    Yeah I have already hit that moment when the arrows on cout should be << not >>.

  6. #6
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    a good book:

    "C++ Without Fear" by Brian Overland (I think that's his name)

    Get a feel for data types before anything. It might seem trivial and boring for you, but you'll thank yourself later.

    Master control statements (if, if/else, if/else if/else, for, while, do/while) -if variables/data are the NOUNS in C++ then control statements are the VERBS...

    Functions -what they are, what they're used for, why they're useful, etc.

    EXAMPLE, AFTER EXAMPLE, AFTER EXAMPLE!!!

    give yourself programs to write, challenge yourself, learn everything you can!

    POINTERS!!! -nuff 'said.

    learn structs & classes. what they are, what they do, etc.

    learn to implement the STL (Standard Template Library) this includes (vector, list, iterator, etc.)

    then, give yourself more assignments & more challenges!

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> a good book: "C++ Without Fear" by Brian Overland

    From what I've seen this is not a good book. It teaches bad habits (like C style strings and plain dynamic arrays). There are other books available that don't have that problem that I would probably look at first.

  8. #8
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    Quote Originally Posted by Daved View Post
    >> a good book: "C++ Without Fear" by Brian Overland

    From what I've seen this is not a good book. It teaches bad habits (like C style strings and plain dynamic arrays). There are other books available that don't have that problem that I would probably look at first.
    But if you're looking for a book that will keep you interested in programming, go with my suggestion.

    It builds on C-Style strings to teach you how to develop a string class (not a bad example by any stretch of the imagination).

    plain dynamic arrays? what?

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> It builds on C-Style strings to teach you how to develop a string class (not a bad example by any stretch of the imagination).

    Does it teach you to use the C++ string class for your string needs? If not, then it doesn't matter whether it uses C style strings for developing a string class, because the reader of the book will develop the bad habit of using C style strings instead of C++ strings.

    >> plain dynamic arrays?
    Bad:
    Code:
    int* dynamic_array = new int[count];
    Good:
    Code:
    std::vector<int> dynamic_array(count);
    >> But if you're looking for a book that will keep you interested in programming, go with my suggestion.

    Perhaps. I can't speak to that part (it's pretty subjective anyway). However, I would rather learn proper habits from a more boring book if I was really interested in the language in the first place.

  10. #10
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    Quote Originally Posted by Daved View Post
    >>
    Does it teach you to use the C++ string class for your string needs? If not, then it doesn't matter whether it uses C style strings for developing a string class, because the reader of the book will develop the bad habit of using C style strings instead of C++ strings.
    Not at all. I never said the book was the only suggestion, it's just one of many. There's no reason to think they can't learn to use <cstring> instead...

    I honestly can't say I wish I had learned PERFECT coding habits up-front, I would have been bored to tears. I first got into programming for game development (like many members here), and now I learn systems in college.

    If I had to worry about the overhead of the most trivial programs, or if I only had the core C/C++ language when I was first learning, I probably would've given up.

    And what's so wrong with C-Style strings? In OS development, C is much more commonly used, and therefore a lot of the syntactic sugars of C++ are non-existent. A real programmer needs to know how to adapt to a situation with whatever tools are given to them.

    What if PCG33K has to rebuild parts of *nix server from source? Guess what? I can almost guarantee C++ strings won't be an option, and for that matter <vector>

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    If you want to program in C, then learn C.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by CornedBee View Post
    If you want to program in C, then learn C.
    +1

    Might I add that it would be completely stupid not to use std::string in a C++ application where speed is not critical.

  13. #13
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    I'm sorry guys. I don't mean to step on anyone's toes, I accept that this is a *C++* forum, and therefore the threads should revolve around *C++*.

    IMO there is nothing wrong however with learning alternatives to the status quo. I agree, the implementation of std::string is a wonderful thing, and I too wouldn't use anything else in a C++ program where there was heavy usage of *strings*.

    I would say, learn C++ first, before C or any procedural lang. I see less problem with people migrating from OOP to lower-level langs than vice versa.

    One of the first books I ever read on C++ was the one I mentioned. At the same time, I was in my beginning programming classes. In those classes, we used std::string. So I didn't give much credit to the string class the author develops, accept for it taught me something about classes (which I feel is not a bad thing).

    In the other thread CornedBee, you said:
    And how do you know how we learned classes?

    I'm glad to say that I didn't learn classes by having people on the internet make me "consider" brain-dead designs.
    You're right I don't know how you learned classes, but I would venture to say most people don't LEARN classes by designing very useful ones. I can recall one example I learned that was something like:
    Code:
    class cat
    {
        public:
            cat(){ age = 0; }
            void meow(){ cout << "Meow." << endl; }
            void setAge(int a){ age = a; }
            int getAge(){ return age; }
           ~cat(){ cout << "Screeeeeech!  Thud!" << endl; }
    
        private:
           int age;
    };
    Is this a *brain-dead* design as you put it? Almost certainly. But it was one of those *baby-step* designs that helped me learn something about the structure of a class. It's merits I'd say are equal to that of a "Hello World!" program, not particularly useful, except as a learning tool.

    So I would say to the OP, learn the difference between C and C++ (when you see something like <stdio.h>, let that be a hint...) C++ strings are good for C++ but non-existant in C. And almost certainly at some point, you will come across something claiming to be C++ but is really C, and for that reason alone, it might not be a bad idea to know what it looks like.

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Is this a *brain-dead* design as you put it? Almost certainly.
    No, it's not. The class may be rather useless, but it isn't poorly designed.

    As for C-style strings, yes, you should learn them, but only after you've got a good seating in the easier parts of the language.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #15
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    You're a gent CornedBee, if I can rightly assume you're infact a *him*!

Popular pages Recent additions subscribe to a feed