[C++] Learning a programming language

In summary: The best way to learn how to write code is to write code. Pick some problems that you are interested in and try to write code to implement these problems.eg. Barjne Soustroups one
  • #1
trollcast
Gold Member
282
13
I'm trying to learn C++ at the minute and I've managed to get over the basics, I/O, Conditionals, Repetition up to and a bit of pointers.

Now what I'm wondering is should I get a textbook that is solely on C++, eg. Barjne Soustroups one, and learn specifically C++.

Or learn by doing problems on places like Project Euler and prehaps maybe a book on another topic that's written in C++, specifically something like this: https://www.amazon.com/dp/032144146X/?tag=pfamazon01-20 , and learn from the code examples and practice?
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
The best way to learn how to write code is to write code. Pick some problems that you are interested in and try to write code to implement these problems.
 
  • #3
trollcast said:
eg. Barjne Soustroups one

You mean this one?

https://www.amazon.com/dp/0321543726/?tag=pfamazon01-20

I haven't seen it myself, but it's gotten good reviews on Amazon, and I think anything Stroustrup writes about C++ is worth reading. I see a new edition of his "bible" is coming out in May:

https://www.amazon.com/dp/0321563840/?tag=pfamazon01-20

I wouldn't use it as a textbook, although some people claim to have done that. I think of it as the ultimate reference. Over the years, previous editions have been my "go-to" book when I want to refresh my memory about some C++ feature.

Depending on your learning style, you might also consider https://www.amazon.com/dp/020170353X/?tag=pfamazon01-20 by Koenig and Moo. Its strong point is in learning how to use the standard "containers" in the C++ standard library, or what many books still call the "STL" (Standard Template Library): vectors, lists, etc. instead of plain old arrays. It's all based on one or two examples which are developed progressively in succeeding chapters, instead of using free-standing examples in each chapter. So it's best read through (and worked through) from beginning to end, which isn't good if you like to jump around depending on which topic catches your fancy at the moment.
 
Last edited by a moderator:
  • #4
trollcast said:
I'm trying to learn C++ at the minute and I've managed to get over the basics, I/O, Conditionals, Repetition up to and a bit of pointers.

Now what I'm wondering is should I get a textbook that is solely on C++, eg. Barjne Soustroups one, and learn specifically C++.

Or learn by doing problems on places like Project Euler and prehaps maybe a book on another topic that's written in C++, specifically something like this: https://www.amazon.com/dp/032144146X/?tag=pfamazon01-20 , and learn from the code examples and practice?

Trying to learn C++ by doing Project Euler is going to discourage you quite a bit. It's not an easy task. Project Euler is very difficult (at least it was for me). It requires better knowledge in math than it does programming, and I'm the other way around.
 
Last edited by a moderator:
  • #5


I would recommend a combination of both approaches. Learning from a textbook specifically focused on C++ can provide a solid foundation and understanding of the language's syntax and structure. However, it is also important to apply that knowledge in practical settings, such as solving problems on platforms like Project Euler or working through code examples in a book on a related topic.

By combining these two approaches, you can gain a deeper understanding of the language and how to effectively use it in real-world scenarios. Additionally, practicing with different types of problems and code examples can help you develop your problem-solving skills and become a more well-rounded programmer.

I would also suggest seeking out online resources, such as forums or coding communities, where you can ask questions and learn from others who are also learning or experienced in C++. This can provide valuable insights and help you improve your skills even further.

In summary, a combination of a focused textbook and practical application through problem-solving and code examples is a strong approach to learning a programming language like C++. Keep challenging yourself and seeking out new resources and opportunities to practice and improve your skills.
 

FAQ: [C++] Learning a programming language

What is the best way to learn C++?

The best way to learn C++ is to start with the basics, such as syntax and data types, and then move on to more advanced concepts like pointers, classes, and algorithms. It is also important to practice regularly and work on projects to solidify your understanding.

How long does it take to learn C++?

The amount of time it takes to learn C++ varies for each individual. It depends on factors such as previous programming experience, dedication to learning, and the complexity of the concepts being learned. However, with consistent practice, most people can become proficient in C++ within 6-12 months.

Do I need a programming background to learn C++?

While having a programming background can be helpful when learning C++, it is not necessary. C++ can be learned by anyone with a strong logical and analytical mindset, and the willingness to put in the time and effort to learn the language.

What are some resources for learning C++?

There are many resources available for learning C++, such as online tutorials, books, and video courses. Some popular resources include "C++ Primer" by Stanley B. Lippman, "The C++ Programming Language" by Bjarne Stroustrup, and the official C++ website (cppreference.com).

What are the common challenges when learning C++?

Some common challenges when learning C++ include understanding memory management, grasping the concept of object-oriented programming, and dealing with the intricacies of the language's syntax. It is important to stay patient and persistent when facing these challenges and seek help from experienced programmers or online communities if needed.

Back
Top