Accelerated C++: Practical Programming by Example

Category: Programming
Author: Andrew Koenig, Barbara E. Moo
4.0
This Month Reddit 3

Comments

by Mydrax   2019-08-24

Well, this is usually because C++ is not really a beginner friendly language. You need to understand the architecture/fundamentals of a computer system at times to understand certain concepts and are often difficult to understand ex: pointers, dynamic memory allocation etc. and with C++ you never finish learning!

Yes, you are very correct about understanding basics before doing actual game-based programming, C++ Primer is pretty old but it's definitely a golden book alongside it though for someone like you I will suggest some of the books I read a couple years back and some that I believe are better for beginners:

Accelerated C++: Practical Programming by Example

Programming: Principles and Practice Using C++

The C++ Programming Language, 4th Edition- Very big book, read this after you've read the rest.

And a book that I've heard is pretty good for game development with c++: https://www.amazon.com/Mastering-Game-Development-professional-realistic/dp/1788629221

by Octa581   2019-08-24

>After reading all the comments, I ve decided to pick up C# and learn it this summer. If and hopefully I will manage to do it by then, I ll start working in unity and focus on it for half a year or so. Then I ll study C++ and switch to Unrea(as both are more advanced as far as I ve understood)!
>
>Here are the following books I ll use to learn C#: "Yellow Book" by Rob Miles along with "Begin to code wtih C# " and also try The C# "Player's Guide"
>
>For Unity: their website, a lot of youtube tutorials
>
>And for C++: "Accelerated C++: Practical Programming by Example"
>
>
>
>If you guys have better suggestions I`m all ears.Thank you all for the help, really means a lot to me!

by thepinkbunnyboy   2019-08-24

This book is made for your use case, you can probably find it free somewhere

https://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X

by Patrick   2019-07-21

http://www.amazon.co.uk/Accelerated-Practical-Programming-Example-Depth/dp/020170353X/ref=sr_1_4?ie=UTF8&s=books&qid=1235080299&sr=1-4

is great for c++, you'll know the .net from your c#

by anonymous   2019-07-21

Here are 3 suggestions depending on your goal:

If you want to understand conversion rules better:

  1. read the relevant parts in the book Accelerated C++ (preference, steps in conversion)
  2. read the relevant parts in the book More Effective C++ (no more than 1 implicit conversion)
  3. read the C++ standard, e.g. the C++14 draft

If you want to find some bug:

  • use printf-debugging or logging in your ctors
  • or use a debugger
  • or break down your code into smaller steps, e.g.

    E e;       
    auto i = static_cast<u32>(e);
    func(i);
    

    static_cast<u32>(e) uses explicitly typed initializer idiom (see Effective Modern C++ Item 6)

If you want to avoid bugs, you should avoid too complex implicit conversions and be wary of user-defined conversion functions (More Effective C++ Item 5). For instance:

  • explicit conversion ctor: explicit A(u32 i){};
  • scoped enum: enum class E{...}
  • scoped enum as ctor parameter: A(E enumElement){};
by anonymous   2019-07-21

This is a working main that uses the Student class that you've defined:

int main() {
     int totNumStudent = 20;
     Student* table = new Student[totNumStudent];

     // Your table contains all the students initialized using the constructor
     // with no-parameters

     for(int i = 0; i < totNumStudent; i++) 
         std::cout << table[i].getId() << std::endl;

     delete [] table; // deallocate the memory for the table
}

I think that you need to read a well-written book for C++. There are tons of them.

I feel to suggest to you Accelerated C++ which is pretty simple and let you to understand the basic C++'s topics.

by anonymous   2019-07-21

I originally wasn't going to answer as there is a lot here for beginning c++ but I thought it might be beneficial to give you a highlevel overview and make you aware of the learning curve involved. I think you should slow things down and take a look at a book like Accelerated C++ http://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X which will cover all these things and have you understanding all this stuff in a matter of weeks. I have not done c++ programming for a while but will try to give a brief explanation of some basic points that you have not understood above:

The header files are used to help speed up compile time and also to organise your code. If everything was in a single file (and you could write all of the above in a single file if you wanted to), any change to that file would have to recompiled. By splitting things up, you get advantages of compile speed (in large projects) and separating the interface from the implementation. You can think of the header file as declaring what the cpp file is going to implement. For example, you can the that the init() method is declared in the header file and implemented in the .cpp file.

Some other points:

  1. #ifndef / #define are header guards in this example. It tells the compiler to process this file if it has not already done so. These are preprocessor directives and can be used in many different ways that you shouldn't worry about now.

  2. const when it occurs after a function declaration means that the function cannot change any class variables. You will have to read more on this by googling "const correctness" as const is used in lots of different ways within C++.

  3. the ~ is a destructor. It is used to destroy an object in memory. There is plenty of documentation all over the internet about constructors and destructors.

  4. the main file is the entry point to the program. It uses the class you wrote in the other files. If you learn how to write a few simple programs, this will all make sense.

I think this is more than enough for now.

by anonymous   2018-05-09
@PetriuxDNezinau in this case, try to get at least comfortable with C `struct`s and use a list of those, because (ab)using plain C strings is not going to work in the long term, imho. Or at least use integer constants instead of C strings. If you want a good book to get up-to-speed with C++, you could read [Accelerated C++](https://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X).
by i45_n5   2018-03-10
As for "Stop Teaching C" video one should also consider this book https://www.amazon.com/Accelerated-C-Practical-Programming-E... Alas, it is c++03. On the other hand it's relatively thin and it begins with the standard library (std::vectors, std::sort, std::string) from the first chapters. So I guess it was the first good book that didn't begin with C language from the start.