- "Jonathan Blow: "C++ is a weird mess"" - 9 Updates
- Concept for location - 1 Update
- I'm narrowing it down, hopefully. - 1 Update
Lynn McGuire <lynnmcguire5@gmail.com>: Jul 23 05:17PM -0500 On 7/19/2018 3:44 AM, boltar@cylonHQ.com wrote: ... > I've seen it in my 20+ year career on one hand. To me it seems like one of > those features that should be useful but almost never is because composition > or aggregation are almost always a better solution. Yes, we use multiple inheritance to combine a modeless MFC dialog with our own private dialog class. Worked well. Lynn |
Lynn McGuire <lynnmcguire5@gmail.com>: Jul 23 05:20PM -0500 On 7/23/2018 5:17 PM, Lynn McGuire wrote: > Yes, we use multiple inheritance to combine a modeless MFC dialog with > our own private dialog class. Worked well. > Lynn class ViewSummary : public CDialog, public DesDialog { // Construction public: ViewSummary(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(ViewSummary) enum { IDD = IDD_VIEWSUMMARY }; //}}AFX_DATA CString m_documentName; COLORREF m_crConvergence; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(ViewSummary) public: virtual BOOL Create(CWnd* pParentWnd, CString documentName); //virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void PostNcDestroy(); virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) override; //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(ViewSummary) virtual void OnOK(); afx_msg void OnDblclk101(); afx_msg void OnDblclk201(); virtual BOOL OnInitDialog(); afx_msg void OnTheWorks(); afx_msg void OnMaterialBalance(); afx_msg void OnStreamSummary(); afx_msg void OnDetailedStream(); afx_msg void OnEquipmentSummary(); afx_msg void OnCaseStudyOnly(); afx_msg void OnGoToErrorPage(); afx_msg void OnGoToIndexPage(); afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); afx_msg void OnHelp(); afx_msg void OnConfigurationOptions(); afx_msg void OnAllStreams(); afx_msg void OnSelectedStreams(); afx_msg void OnDblclk112(); afx_msg void OnAddOne(); afx_msg void OnAddAll(); afx_msg void OnRemove(); afx_msg void OnToTop(); afx_msg void OnMoveUp(); afx_msg void OnMoveDown(); afx_msg void OnToBottom(); afx_msg HBRUSH OnCtlColor (CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg void OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct); //}}AFX_MSG DECLARE_MESSAGE_MAP() virtual void OnCancel(); void getSolutionMessage (FILE *of); void initListBoxes (FILE *of); }; Lynn |
Cholo Lennon <chololennon@hotmail.com>: Jul 24 01:44AM -0300 On 07/23/2018 12:45 PM, Richard wrote: >> unnecessary IMO :-O > File bugs. JetBrains is much more responsive to my bug reports than > other software vendors. That's good to know, I'll do it. -- Cholo Lennon Bs.As. ARG |
Thiago Adams <thiago.adams@gmail.com>: Jul 24 05:35AM -0700 On Monday, July 23, 2018 at 7:18:01 PM UTC-3, Lynn McGuire wrote: > > or aggregation are almost always a better solution. > Yes, we use multiple inheritance to combine a modeless MFC dialog with > our own private dialog class. Worked well. I think you are using inheritance in this case to inject functions. Maybe you wish to add function inside the CDialog but because it is not your code then you had to use another base class. The alternative design is create free functions and pass the 'this' pointer as parameter. The code using inheritance is much harder to reasoning about considering the base class has access to all protected members and consequently is less encapsulated compared with free function where you only can access public data/functions. If you need to inject more functions you have to create more base classes and at some point you will have to select sets of functions that make sense to you. Using the alternative, free functions, you may have to select the best header to group functions but you can more easily (less code to type) apply changes. Use inheritance to get implementations can be good to avoid to implement the same code in different objects but at the same time can create a difficult common denominator for all derived classes creating a very coupled problem. This is something very apparent when you realize you have some virtual that doesn't make sense in your object but you need to implement it doing nothing just follow the interface. Other languages, like C#, that don't have free functions had to create a mechanism to archive similar functionality called extension methods. |
Thiago Adams <thiago.adams@gmail.com>: Jul 24 06:16AM -0700 On Monday, July 23, 2018 at 12:41:03 PM UTC-3, Richard wrote: > space. This is one of the problem domains that is very "mathematical" > in nature and overloading the arithemetic operators makes very good > sense. To get the benefits of math notation you also need to use exceptions. Are you using exceptions? And also you lost the control about how the computation is done. For instance, sometimes we can do the calculation "in place" the matrix is in/out at the same time avoiding temporaries. Or we can arrange temporaries to avoid recalculation, because math expressions don't care how the computation is done. Also math expressions don't care about floating /overflow problems. I remember in C++ 03, the C++ programming language book, Stroustrup showed some tricks to avoid temporaries in matrix multiplication. I think now this is done using move semantics. Some expressions are better if specialized functions like hypot are used. For these reasons, something I would like to have, or to do is a especial transpiler where we could just write the math expression as it is (in a declarative way), and the transpiler would create the computational steps trying to reasoning about errors/overflow and creating the minimum steps (performance) to archive the computation (imperative version) of the expression. Then, for instance if the input was sqtr(x^2 + y^2) the output would be hypot(x, y) if the input was X^2 the ouput could be x*x or alternatively using pow depending on the exponent. For big matrices I also think the transpiler could take advantage of many cores. I am sure I can find much more sample then I believe this tool would be useful. I don't need too much math expression in by job and this is one reason I didn't make this transpiler yet. This also shows that C++ syntax using operator overloading and exceptions can represent math expressions but sometimes for real code we need to think about how the computation is done and make the steps manually. I have one more sample that is for chart applications where the used can do infinite zoom at the screen I had to define the limit to avoid overflows. To do that I am not using the full expression and waiting for some exception, but instead, I can handle the problem using only the "zoom factor" instead of all expression. For the time axis I used 64 integers then I have the perfect overflow check. |
Thiago Adams <thiago.adams@gmail.com>: Jul 24 06:56AM -0700 On Tuesday, July 24, 2018 at 10:16:31 AM UTC-3, Thiago Adams wrote: > of all expression. > For the time axis I used 64 integers then I have the perfect > overflow check. I just open the book The C++ programming language C++ 11, on page 853, 29.5.4 Fused operations Then he defines other types to represent expressions MVMult and MVmulvAdd to archive the thing I was talking about to avoid temporaries,reuse loops and keeping the math syntax. |
Ian Collins <ian-news@hotmail.com>: Jul 25 09:24AM +1200 On 25/07/18 01:16, Thiago Adams wrote: > To get the benefits of math notation you also need to use > exceptions. Are you using exceptions? > And also you lost the control about how the computation is done. You can write your maths routines however you like, optimising where required. Our positioning system algorithms makes extensive use of optimised matrix maths routines. > would create the computational steps trying to reasoning about errors/overflow and creating the minimum steps (performance) > to archive the computation (imperative version) of the > expression. You appear to be describing MatLab code generation.. -- Ian. |
legalize+jeeves@mail.xmission.com (Richard): Jul 24 09:33PM [Please do not mail me a copy of your followup] boltar@cylonHQ.com spake the secret code >Does multiple inheritance get used much anyway? Yes. Oh, you wanted more? People use private inheritance for composition of implementation, for example. It is the core building block of composing objects with ATL. Read "ATL Internals" for a really good design stufy of templates and composition of implementation through inheritance. It is worth reading even if you don't plan on ever writing COM objects on Windows. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): Jul 24 09:34PM [Please do not mail me a copy of your followup] Thiago Adams <thiago.adams@gmail.com> spake the secret code >And also you lost the control about how the computation is done. Welcome to any language except assembly language. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jul 24 08:29PM > - Enforce at compile time that an object can only be instanciate > - on the stack. This is to implement a "safe" dynarray type like > - object. Misfeldt et al (2004): Elements of C++ Style, item 102: class Foo { private: void* operator new(size_t); void* operator new[](size_t); }; I suppose nowadays you'd say "... = delete". > - Enforce at compile tiem that an object can only be instanciate > - on the heap. This is to ensure That no "Big" object are > - instanciated on the stack. Item 103: class Foo { private: friend class std::auto_ptr<Foo>; ~Foo(); }; I haven't tried either of these, but I'm generally for removing features you don't plan to use. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Jeff-Relf.Me @.: Jul 23 04:34PM -0700 |
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