As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have been coding in java most of the time, and I also studied C and C++ at University. But I have never written a large C++ code from zero made of many files, as I have done in java with a file for each class.
I'd like to know some book or reference with exercises and examples made of many files and classes en C++, so I can face big C++ projects in the future.
Sorry if you feel this question is eternally repeated.
Large-Scale C++ Software Design, by John Lakos.
Frankly, it doesn't matter much which language you're using in the end. Good software design is good software design. I don't think you'll ever learn it from a single book - and most books that talk about that kind of thing are referring to designing large frameworks which I doubt you're doing.
Identify sub-components/functionalitities in your requirements that you can form into separate libaries (static or dynamic, read up on the difference). If you compartmentalize these components into libraries that can act independently of each other then you'll have loose coupling between libraries - and assuming you've correctly identified your sub-components, they should have high-cohesion (everything in a library is closely related).
Try and keep dependencies out of your header files whenever possible regardless of where you're coding - you should read up (even on google) about separating declaration from definition). There's a number of design patterns for this purpose (including PIMPL which I seem to be mentioning alot today).
Read the design patterns book by the Gang-of-Four, and do the above, and you'll be off to a good start. Also, assuming you're decent with C++, Effective C++ by Scott Meyers will talk about some of these topics in very helpful manners.
Good design is a key on large projects and it is doesn't matter which language do you use if you follow the OO concept.
But for some best practices in c++ you could read this book:
http://www.gotw.ca/publications/c++cs.htm
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I know this could be seen as subjective off-the-cuff (thus a poor question), but bear with me.
Boost has recently become available on the project on which I'm working, and I don't have much experience with it. Boost has so many parts and features that it's hard to know where to get started in learning it - especially since I'll be trying to learn it while making production code.
So, I would greatly appreciate it if someone could list around 3 to 5 features which are very useful in general, every-day programming and state why they're useful. I'm not asking you which is best, or trying to get a debate - I just want to know some good features to start learning and using immediately. I don't need code samples either, I'll be more than happy to research how to use the features myself after I know which ones are sensible to start learning now.
I'll accept any answer with a concise list of features that are sensible :)
format and lexical_cast are great for string manipulation, I find them invaluable. I use them every day.
bind is great for ad hoc functors, you'll find it is reused throughout many of the boost libraries.
multi_index fills the gap of when you need the same data in two search structures at once, it is very handy at times. Keep it out of your headers though.
type_traits defines useful traits for template specializations.
signals is a signal/slot mechanism implementation, great for event driven designs.
shared_pointer is critical. It lets you automatically handle memory usage.
http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/shared_ptr.htm
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am working as c++ developer in cfd field for last 1.5 years. Since I am from computer science background I have very poor domain knowledge in CFD. I have searched on net but didn't get the kind of material am looking for. Actually am getting mathematical research papers about cfd focusing on theory and formulas . What I want is a tutorial written in plain English targeting novice people with focus on software development. I might be asking too much , but any help is appreciable :)
Well, if you want to have a somewhat more friendly introduction (although you simply won't be able to escape math) you might start at "Fluid Flow for the Rest of Us" by Cline, Cardon and Egbert and work your way up from there. Google it and you'll find it online.
Or you could have a look at Robert Bridson's book "Fluid Simulation for Computer Graphics" which introduces the basic concepts in a more gentle way.
These are both texts dealing with fluids targeted at computer graphics, but they might provide a gentle introduction while you work your way up to CFD simulations.
I've worked with/on two C++ libraries that both come with a lot of theory, docs and tutorials: http://www.dealii.org/ and http://libmesh.sourceforge.net/. Both are adaptive refinement finite element libraries, both with a focus on (scientific) fluid simulations.
Another good start could be Fast Fluid Dynamics Simulation on the GPU, which actually lends to a very simple (but not optimal) implementation on the CPU.
It comes with shader's source that can be ported straight to the CPU, and provides an easier and more programming oriented approach than Bridson's book.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Does anyone know any site or book that presents problems like python challenge, but for C++?
When I think python challenge, I do not mean only a set of problems to be solved with C++ (for that I could probably use the same problems of python challenge), but rather problems that will probably be best solved using C++ STL, special features of the language, etc.
For example, there is one python challenge that is specifically designed to teach you how to use pickle, a serializing library for python.
Until now, I only know programming contests problems, but they could also be solved with C, java or other languages.
You might like to have a look at Herb Sutter's Guru of the Week series of articles.
Google Code Jam problems frequently have analyses with snippets of C++ code, probably because C++ is by far the most popular language used for solving code-jam problems. The latter also allows you to see many C++ constructs cleverly employed, as code-jam allows you to download the solutions by all the competitors. As most code is C++, you'll get to learn a lot of nice C++ tricks for efficient code.
There are many tasks on Rosetta Code that are not implemented in C++ as yet. Try your hand at those, especially if you can use advanced features (templates, external libraries, etc.) to produce a particularly nice solution. Remember that there is no fundamental reason why any of those tasks should be beyond the C++ language, and there's usually several other implementations in other languages to show you other ways to attempt the task, which can help a lot.
You're going to have a difficult time finding that because C++ provides less for you than almost any other language available. If C++ provides it, it's probably provided by Python or Java or C or any other programming language.
Why not try using some C++ concepts such as the STL to solve Project Euler problems?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have been programming exclusively in C for 25 years but have never used C++. I now need to learn the basics of C++ programming. Can anyone recommend an online tutorial (or failing that a book) that would be most suitable for me.
Thanks.
Edit: I actually needed the C++ purely for the purposes of adding a couple of dirty hacks to a huge and old C program. Converting the entire program in to properly written OO code is entirely economically unfeasible. Some people have criticized the suggested solutions based on the fact that they will lead me down the path of becoming a "C programmer who knows some C++ without getting in to the proper spirit of C++" - but actually that fits my requirements perfectly.
Edit: The link in the top voted answer seems to be broken right now but the file appears to exist in multiple places - e.g. here.
This might be of some use: C++ tutorial for C users.
If you're looking for a book, check out "C++ for C Programmers" by Ira Pohl (Amazon).
I found Thinking in C++ very good when I was going from C to C++.
Link broken - can now be found here
I'd like to suggest the New C++ Super-FAQ created by Bjarne Stroustrup, Herb Sutter, Andrei Alexandrescu, Pearson / Addison-Wesley Publishers and Marshall Cline (http://www.parashift.com/c++-faq/).
If you can get hold of a 2nd edition of Scott Meyer's "Effective C++", that should help, as it was written for former C developers. It lists 50 rules that you should follow which are easily to remember, thoroughly explained, and fun to read. (Scott's goal was to write the "best 2nd C++ book" one should read an I think he succeeded in that.)
The 3rd edition of the book was completely overhauled and targets developers coming from C#, Java etc. more than earlier editions. It might be good read nevertheless.
Accelerated C++ is good too.
This very recent SO question asked by an inexperienced C programmer nevertheless has answers that are also relevant to experienced C programmers.
If you're already a good C programmer, you can probably jump right into the bible, Stroustrup's The C++ Programming Language.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Do you know of well designed open source applications that are instructive to analyse?
Specifically, I'm interested in practical applications object-relational mapping in C++ based programs, where there is a good separation between a domain model and persistence/serialization functionality.
If you include well designed open source libraries that are instructive to analyse, have a look at Boost.
About persistence / serialization (not relational mapping though), have a look at Boost Serialization, you might find nice ideas!
"...one of the most highly regarded and expertly designed C++ library projects in the world."
— Herb Sutter and Andrei Alexandrescu, C++ Coding Standards
"Item 55: Familiarize yourself with Boost."
— Scott Meyers, Effective C++, 3rd Ed.
"The obvious solution for most programmers is to use a library that provides an elegant and efficient platform independent to needed services. Examples are BOOST..."
— Bjarne Stroustrup, Abstraction, libraries, and efficiency in C++
While this doesn't fit your specific requirements (it's not a business app for a start), I think that OGRE 3D is a great example of an open source C++ project.
V8 javascript engine is said to be very well engineered. http://code.google.com/p/v8/
Google Chrome also has an interesting architecture and high quality code base. http://code.google.com/chromium/
Both are open source, under BSD-like license.