Help with this.

This is a discussion on Help with this. within the C++ Programming forums, part of the General Programming Boards category; The one I found online uses std:: cout << '\n'; or something like that. Just make it std::endl and continue ...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    The one I found online uses std:: cout << '\n'; or something like that.

    Just make it std::endl and continue with the book. Occasionally there will be typos that you have to figure out. That errata isn't much help for the 5th edition, sorry.

  2. #17
    Registered User
    Join Date
    Oct 2007
    Posts
    15
    Quote Originally Posted by Daved View Post
    The one I found online uses std:: cout << '\n'; or something like that.

    Just make it std::endl and continue with the book. Occasionally there will be typos that you have to figure out. That errata isn't much help for the 5th edition, sorry.
    Oh alright. ^^: Thank you <3.

    Hah I remember finding an error in one of our physics text books in 10 grade. Besides the point , the is still grade A I suppose then.

    Oh my god o________O look at all the errors in the other editions.

  3. #18
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Validinfection View Post
    Oh my god o________O look at all the errors in the other editions.
    Hehe. That sounds like me.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #19
    Registered User
    Join Date
    Oct 2007
    Posts
    15
    Another lame question.


    Do you have to do each section a day?.. Or can you go on to other sections and complete and still grasp all their information, in one day?... Heh I know I guess this is personal choice, just curious.

  5. #20
    Registered User
    Join Date
    May 2007
    Posts
    77
    I'd say, if you think you can continue, and still grasp what they're teaching, go ahead. If you finish the book before the "21 days" are up, go through it again. It will only serve to solidify it in your mind.

    Now, for more error fixing:
    Code:
    #include <iostream>
    int main()
    {
        int x = 5;
        int y = 7;
        std::cout << std::endl;
        std::cout<< x + y << " " << x * y;
        std::cout<< std::endl;
        char response;
        std::cin >> response;
        return 0;
    }
    Also, I would second second the motion to use "using namespace std;" because the code would then look like this:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int x = 5;
        int y = 7;
        cout << endl;
        cout<< x + y << " " << x * y;
        cout<< endl;
        char response;
        cin >> response;
        return 0;
    }
    A bit cleaner and clearer, eh?

    Tell me, what is the purpose of having "cin >> response;" in there? There's nothing to respond to. If that's supposed to be a trigger to keep the program from exiting automatically, just replace it with " system ("pause"); ". That way, you don't have to declare an extraneous variable.

  6. #21
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    No matter how long it takes you to go through the book (it should probably take more than 21 days, though), you should get a different book and go through that to augment your learning. There are only a few books that teach modern C++, and Liberty's book is not one of them (even though Brad Jones has said that he has tried to get it updated... it hasn't happened yet).

    The perfect book to follow up with is Accelerated C++ by Koenig and Moo. It might even be smart to switch to that now, if you are really interested in learning good modern C++ practices and techniques rather than general programming skills.

    BTW, I personally prefer to add std:: to all names in the std namespace. It is more consistent because there are situations where a using directive is bad practice. I also find it easier to read despite the added clutter.

  7. #22
    Registered User
    Join Date
    May 2007
    Posts
    77
    I look forward to the time when I encounter that situation myself.

  8. #23
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    using namespace std is bad practice in a header file. So now that you are starting to use other headers you have already found such a situation.

  9. #24
    Registered User
    Join Date
    May 2007
    Posts
    77
    So you only want to use it in the .cpp files? If then, I'm guessing?

  10. #25
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    I always use std:: in all files, header or source. It is bad practice to use the "using namespace std" in a header file. It is usually fine to do it in a source file, but I prefer to be consistent and do it in neither. For simple beginner code it really doesn't matter much at all, although it is wise to follow good habits for the future.

  11. #26
    Registered User
    Join Date
    Oct 2007
    Posts
    15
    Quote Originally Posted by Daved View Post
    No matter how long it takes you to go through the book (it should probably take more than 21 days, though), you should get a different book and go through that to augment your learning. There are only a few books that teach modern C++, and Liberty's book is not one of them (even though Brad Jones has said that he has tried to get it updated... it hasn't happened yet).

    The perfect book to follow up with is Accelerated C++ by Koenig and Moo. It might even be smart to switch to that now, if you are really interested in learning good modern C++ practices and techniques rather than general programming skills.

    BTW, I personally prefer to add std:: to all names in the std namespace. It is more consistent because there are situations where a using directive is bad practice. I also find it easier to read despite the added clutter.
    This is only to get my feet wet in c++ programming, I'll buy more books. Also I plan to become a programmer, going into college for computer science, etc.

  12. #27
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    its better to start with a more simple language than c or c++. I would start with a flavor of basic do to the lack of cryptic language. That way you can get a hold on programming in general with out all the cryptic words etc. Once you learn how syntax works etc you can learn pretty much any language with out the hassle of remembering all the tricks of a hard language as well as learning how to program.
    -- Will you show me how to c++?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21