comp.lang.c++@googlegroups.com | Google Groups | ![]() |
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
- Difference between data structures - 2 Updates
- C++ Books for new C++ Programmer (who is experienced in C and Python) - 5 Updates
- unable to delete the value from a vector. - 2 Updates
- How is it this code compiles without errors in VS 2013 ? - 1 Update
- How to organize class member variables and functions - 1 Update
- Free C/C++ static code analyzer CppCat for Students - 1 Update
"K' Dash" <adnanrashidpk@gmail.com>: Nov 24 01:43PM -0800 What are the main differences between Vector an Map? |
Barry Schwarz <schwarzb@dqel.com>: Nov 24 03:32PM -0800 On Mon, 24 Nov 2014 13:43:28 -0800 (PST), "K' Dash" >What are the main differences between Vector an Map? They are described in different sections of your reference and tutorial manuals which should provide you with as many additional details as you need. -- Remove del for email |
JiiPee <no@notvalid.com>: Nov 24 12:55AM On 23/11/2014 21:42, Öö Tiib wrote: > sub-sequences between sequence containers then 'std::list' is among winners > and hard to beat. Such problems are rare and 'std::list' is not that good > for most other things so it should not be the first choice of container. Yes true. So one have to check what kind of situation it is to know what is best for each case. Sometimes its vector sometimes list. |
JiiPee <no@notvalid.com>: Nov 24 12:56AM On 23/11/2014 19:52, Ian Collins wrote: > woodbrian77@gmail.com wrote: >> I don't find much use for ::std::list, ::std::set or ::std::map. The use is if there is a big junk of data needs to be moved around, list is much faster then. |
legalize+jeeves@mail.xmission.com (Richard): Nov 24 02:04AM [Please do not mail me a copy of your followup] Chicken Mcnuggets <chicken@mcnuggets.com> spake the secret code >and am thinking about buying: >Effective C++ 3rd Edition Here's my review: <http://legalizeadulthood.wordpress.com/2009/09/09/effective-c-3rd-edition-by-scott-meyers/> Recommended. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): Nov 24 02:24AM [Please do not mail me a copy of your followup] Chicken Mcnuggets <chicken@mcnuggets.com> spake the secret code >The big problem area for me with C++ is templates and how to incorporate >them into my code (and whether I should do or if I should use another >solution instead). You should be consuming the template container classes from the C++ library and resource handle classes like unique_ptr<T> and shared_ptr<T>. After that, only if you have duplication in your code where the duplication varies only in the types involved and not the expressions should you then consider adding your own templates to your code base. This would be using 'static polymorphism' via templates to eliminate duplication instead of 'dynamic polymorphism' via virtual member functions and pointers to base classes to eliminate duplication. The most important thing when extending your code is to maintain readability and expressiveness. Templates can introduce a whole bunch of syntactic noise and reduce readability and expressiveness. If I had to give up readability to eliminate duplication, I might just keep the duplication (and I *abhor* duplication). -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 24 11:00PM On Mon, 2014-11-24, Richard wrote: > [Please do not mail me a copy of your followup] > Chicken Mcnuggets <chicken@mcnuggets.com> spake the secret code > <wrhcw.822436$Au1.267552@fx36.am4> thusly: ... > of syntactic noise and reduce readability and expressiveness. If I > had to give up readability to eliminate duplication, I might just keep > the duplication (and I *abhor* duplication). Fair enough, but templates can just as well make the code /more/ readable. Saying the same thing many times in slightly different ways can (like you say) be really distracting. I suppose being able to see what's esentially "the same thing" is the key to using templates this way. Here too the OP's Python background can help, since he's used to duck typing. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Juha Nieminen <nospam@thanks.invalid>: Nov 24 10:02AM > for (std::vector<Entry>::iteratori=m_listentry.begin();i!=m_listentry.end ();i++) > if (GUIDaddress== entry.GetGUIDaddress( )) You aren't using the iterator for anything there. How can it match anything inside the vector? --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
"K' Dash" <adnanrashidpk@gmail.com>: Nov 24 01:41PM -0800 thanx Juha Nieminen. you are right. poor programming skills I have. |
Juha Nieminen <nospam@thanks.invalid>: Nov 24 09:56AM > - It's hard to remember to include the exact right set of headers -- I really wish they made inclusion of standard library headers optional. In other words, the the compiler would "include" such headers automatically when it sees that a standard function, type or macro is referenced in the code. (If this could potentially be a source of problems, then I would be completely ready to accept that the automatic inclusion of standard header files is done only when you use the std:: prefix in the name of the function or type. This ought to be easy for the compiler to do.) Code would become cleaner, less prone to errors due to forgotten #include lines, and might even compile a bit faster (because the compiler doesn't need to parse #include lines nor, possibly, the header files themselves). --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
legalize+jeeves@mail.xmission.com (Richard): Nov 24 02:18AM [Please do not mail me a copy of your followup] Start with SOLID principles of object oriented design: <http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)> Some of the stuff you already mentioned falls under SRP. no@notvalid.com spake the secret code >functions inside corresponding class header? I know we should avoid >member functions, but what would be a good rule here which ones to make >global functions and which ones members? The general advice is to make things members that must be members. If something can be achieved outside a member function, then make a free function that achieves it. By this guideline, std::string should not have find_first_of as a member, since the algorithm std::find_first_of already covers the cases handled by the member functions. Convenience functions that delegate to the algorithm instead of methods could have been written. std::string would have far fewer methods without any loss in performance if this advice had been followed for std::string. Its easier to make them >members... Almost all of them are using private members, so is it just >best to make them members even though then I get a lot of member >functions, like 10-15? My advice would be first to split your monster class into a network of cooperating classes that each follow single responsibility principle. Once you do this, clumps of methods tend to move together and you'll find that the number of methods on any single class goes down. >Also as you can see there are very many member >variables as well... should I put all of them inside Game and Graphics >classes, or group them into new structures? Many member variables are also a general indicator that your class has too many responsibilities. Look for clumps of member variables and methods that go together -- for instance a group of methods that access a clump of member variables but none of the other variables. This is a candidate for a new class that has a single responsibility and encapsulates those related member variables. Don't be afraid of small classes that represent one single well-defined responsibility. (Think of something like a two-dimensional point class.) Identify "value types" in your code -- things like string, Point2D, etc., that don't exhibit polymorphism or abstract interfaces. A common example is a Money class that represents some specific quantity of money in a particular currency. For games, try to separate behavior (game play) from graphics (rendering). Some articles on refactoring for C++ that may give you inspiration: <http://legalizeadulthood.wordpress.com/category/refactoring/> -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): Nov 24 02:07AM [Please do not mail me a copy of your followup] Chicken Mcnuggets <chicken@mcnuggets.com> spake the secret code >> development stalled over 10 years ago. >Why not use the Clang static analyser? I use it for C projects all the >time and I know it supports C++. For static analysis, my recommendation is always to use all the tools you can get your hands on: cppcheck, clang static analyzer, msvc static analyzer, lint, valgrind, etc. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment