• Forum
  • Lounge
  • Who else is reading c++ Primer 5th Editi

 
Who else is reading c++ Primer 5th Edition

Pages: 12
closed account (EwCjE3v7)
I was wondering who else is reading this book, I want to know because I would like to take a look at how they did the exercises. This book throws stuff that you have not done, but at least have some kind of answer page or website. The 4th Edition did.
Wish it was like that. :/
closed account (9E360pDG)
i am. It's quite confusing, even in chapter 1. It has no answer to exercises like beginning c++ programming through game programming.
closed account (EwCjE3v7)
Yea, wish it had answers.

I was wondering if you had the exercises that you did, so I could take a look and see how close I was or if I was right.

And a how long have you been reading it for and where are you at.
How much on average do you read per day?
When do you think you will finish

Sorry for all these questions
closed account (9E360pDG)
I haven't gone far but i am not reading it now. I haven't read it this week because i'm busy. By the end of next week or so, i continue with programming.
Sorry. I thought i would be the one needing to check if mine is correct seeing as you have way more posts than mine.
On average, i think i read 2 or 3 chapters while practicing and reapplying. I'll finish before the end or by the start of May (it marks 6 months of learning C++).
It's quite confusing, even in chapter 1.

Wait what? You must be kidding me.

Can you post an example question?
closed account (9E360pDG)
The one that asks you to go on the net and copy and paste a class code.
And how is that so hard? Just go to Google, search for C++ OOP example, click on a link, copy the code and paste it.

BTW, I don't think C++ Class would be in the 1st chapter of any C++ beginner's book. Are you reading C++ Primer or C++ Primer Plus?
Last edited on
closed account (9E360pDG)
C++ Primer. They ask you to search for the class code and ask you to do an exercise on it. How am i supposed to know what's what?
In later chapters, they start talking about how the class is made.
Oh here are some exercises from Chapter #1 and their solutions, which I whipped up myself:

Exercise 1.3: Write a program to print Hello, World on the standard
output.

1
2
3
4
5
6
7
#include <iostream>

int main()
{
    std::cout << "Hello, World" << std::endl;
    return 0;
}


Exercise 1.4: Our program used the addition operator, +, to add two
numbers. Write a program that uses the multiplication operator, *, to print
the product instead.

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

int main()
{
    std::cout << "Enter two numbers: " << std::endl;
    int v1 = 0, v2 = 0;
    std::cin >> v1 >> v2;
    std::cout << "The product of " << v1 << " and " << v2 << " is " << v1*v2 << std::endl;

    return 0;
}


Exercise 1.5: We wrote the output in one large statement. Rewrite the
program to use a separate statement to print each operand.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

int main()
{
    std::cout << "Enter two numbers: " << std::endl;
    int v1 = 0, v2 = 0;
    std::cin >> v1 >> v2;
    
    std::cout << "The product of ";
    std::cout << v1;
    std::cout << " and ";
    std::cout << v2;
    std::cout << " is ";
    std::cout << v1*v2;
    std::cout << std::endl;

    return 0;
}

How am i supposed to know what's what?


You clearly should start from the beginning then.
closed account (9E360pDG)
I know how to do those and more. I'm using 7 books.
7 books??? You should finish one first lol.
closed account (9E360pDG)
All of them have problems. If i wasn't using all those, i won't have understood C++ up to destructors and constructors (still learning though).
closed account (z05DSL3A)
C++ Primer: Preface
Although you do not need to know C in order to understand this book, we assume you know enough about programming to write, compile, and run a program in at least one modern block-structured language. In particular, we assume you have used variables, written and called functions, and used a compiler.
It is not a book for the complete beginners.
Last edited on by Canis lupus
closed account (9E360pDG)
I did that before i got C++ Primer. It's more beginner than Programming: practice and principles using c++.
My Books (in order of purchase):
1) Cplusplus.com pdf
2) Tutorialspoint pdf
3) Programming Practice and Principles Using C++
4) Beginning C++ Through Game Programming, 3rd edition
5) Jumping into C++
6) C++ Primer, 5th edition
7) The internet :)
And for when 6 months is over
8) The C++ Programming Language, latest edition
9) Any Directx book
10) Any Qt book
Last edited on
closed account (z05DSL3A)
It's more beginner than Programming practice and principles using c++.
Really? I think not.
closed account (9E360pDG)
Maybe for you but not for me.
@YellowPyrmid
The exercises are designed to build on what you learned in the sections before it. For example, exercises for section 2.4.2 is to help you understand what is legal and not legal with pointer, reference, pointer to const, reference to const, const pointer, etc. As for the exercises that require you to make applications, they are just build on what you have learned in previous sections and chapters. The best bet for finding the right answers would to post the question and your attempt in the beginner forum and get input from other programmers there.

It's more beginner than Programming practice and principles using c++.

Not even close.

Here are quotes from a very reliable site (ISOCPP) for what books to read in order to learn.
Programming: Principles and Practice Using C++
Are you completely new to programming? If you’ve never programmed before, why not learn in C++?

Programming: Principles and Practice Using C++ is an introduction to programming written by the creator of C++, Bjarne Stroustrup. Thousands of college freshmen taking Stroustrup’s hugely popular Introduction to Programming class at Texas A&M University, and innumerable readers around the world, have learned programming and launched their careers using this book – and C++.

This text reflects the C++98 standard. All of the code examples work in C++11, and the book itself will likely be updated next year to reflect the new standard and its extra conveniences and features.

*Note a new C++11 version is expected out in May 2014.


Tour of C++
Are you looking for “the” one-stop overview of C++?

The new concise A Tour of C++ by Bjarne Stroustrup is the go-to book to answer “what is the book of what you should assume everyone knows about C++?”

Through a modern tour of the language and library, its contents answer the question: What is the basic knowledge that we should be able to assume from a competent C++ programmer?

One could subtitle it: “Around the C++ world in 180 pages.”

C++ Primer
Are you new to C++?

Freshly updated for the new C++11 standard, the bestselling C++ Primer is one of the most popular books ever for learning C++, written by close colleagues of Bjarne Stroustrup who participated in the development of C++ since its early days.

This authoritative and comprehensive introduction to C++ will help you to learn the language fast, and to use it in modern, highly effective ways. Highlighting today’s best practices, the authors show how to use both the core language and its standard library to write efficient, readable, and powerful code.

The C++ Programming Language
Looking for “the” authoritative C++11 reference?

Now also being freshly updated for C++11 and available soon, the all-time best-selling C++ book on the planet is Bjarne Stroustroup’s The C++ Programming Language. This book is primarily a reference, not a tutorial, but it also contains extensive explanations and many valuable insights and guidelines from the creator of C++ himself.

The C++ Standard Library: A Tutorial and Reference
Looking for the authoritative tutorial and reference for the C++11 standard library?

Freshly updated for C++11 and available now, The C++ Standard Library: A Tutorial and Reference by renowned ISO C++ member Nicolai Josuttis is the most respected book for learning and studying the standard library. It provides comprehensive documentation of each library component, including an introduction to its purpose and design; clearly written explanations of complex concepts; the practical programming details needed for effective use; traps and pitfalls; the exact signature and definition of the most important classes and functions; and numerous examples of working code. You’ll find it all here – everything from concurrency and clocks, to the new hash-based containers and regular expressions, to high-quality guidance on how to use key language features like lambdas with it all.



My Books:
1) Cplusplus.com pdf
2) Tutorialspoint pdf
3) Jumping into C++
4) Beginning C++ Through Game Programming, 3rd edition
5) Programming Practice and Principles Using C++
6) C++ Primer, 5th edition
7) The internet :)

1 and 2 are just PDFs of tutorials so they only graze over a few things without going into too much detail.
3 is written by the CProgramming.com administrator, but to me the short comings are that it appears to be just nothing more than his site tutorials in book form. 4 is alright for picking up the language, but it is a little outdated I think unless they released a version that makes use of the new C++11 standard. 5 is the most recommended book for never programming before. 6 is the most recommended book for a programmer who has never used C++ before. 7 is a terrible 'book' as it supplies both good and bad programming resources and some of the bad ones are able to seem knowledgeable enough to fool most beginners who have no one to tell them they are bad, but it can be a valuable reference and resource for finding help.
closed account (EwCjE3v7)
@YellowPyrmid
The exercises are designed to build on what you learned in the sections before it. For example, exercises for section 2.4.2 is to help you understand what is legal and not legal with pointer, reference, pointer to const, reference to const, const pointer, etc. As for the exercises that require you to make applications, they are just build on what you have learned in previous sections and chapters. The best bet for finding the right answers would to post the question and your attempt in the beginner forum and get input from other programmers there.


Yea but explain the Exercise 3.20 on page 105 Vectors this is the code I got

This is what I got
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <vector>
using std::cout; using std::endl; using std::cin;
using std::vector;

int main()
{
    vector<int> storage; // holding the numbers
    int input; // for getting the input
    decltype(storage.size()) counter = 0; // for finding our index

    cout << "Type in two numbers separated by a space: " << endl;

    while (cin >> input) { // while we get input
        storage.push_back(input); // put that at the end of the vector

        if (storage.size()%2 == 0) { // if the vector has even amount of numbers
            cout << "Sum of " << storage[counter] << " and " << storage[counter +1] // print out the sum
                    << " is " << storage[counter] + storage[counter +1] << "\nAnymore?" << endl;
            counter += 2; // same as counter + 2 = counter
        }

    }

    return 0;
}


And I had done the % operator before so I knew about it. If that wasnt there you would have to do a if with a lonnnnnnngggggg condition
closed account (9E360pDG)
@bhx: Thanks a lot (a lot) for grading my book choices.
I just wish 5 could be better but when learning, i tend to use all of them except 5. It decorates the book in a way that is confusing (i love designs but would prefer it wasn't in such a book) and presents code in a confusing way and uses that "std lib facilities whatever".

Please, do explain Yellow pyramid's code
Last edited on
Pages: 12