Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Dialog boxes : why struc instead of class ?
Dialog boxes : why struc instead of class ? [message #31624] Fri, 18 March 2011 10:04 Go to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

In most examples, a dialog box is done this way :
struct MyDlg : public WithMydialogLayout<TopWindow> {
...
}

Why not use a class, something like this :
class MyDlg : public WithMydialogLayout<TopWindow> {
public:
...
protected:
...
private:
...
}


This looks surprising for me, more especially when I see
typedef MyStruc CLASSNAME;


The best reason is surely that it's working well this way, but it's very confusing for beginners !
Re: Dialog boxes : why struc instead of class ? [message #31630 is a reply to message #31624] Fri, 18 March 2011 13:29 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Jibe,

In C++, the only difference between struct and class are in default access right to the members. Class has private members as defualt, struct uses public, otherwise the behavior is the same. So using struct for dialogs in U++ is just laziness to write class XYZ{ public: ... } Wink You can of course use whatever form you like better, there is no functional difference.

The CLASSNAME could be equally well STRUCTNAME (or ASFDGFSDGSDFG or whatever else Very Happy ). I guess it kind of makes sense to call it CLASSNAME though, because class is well defined, while struct can be C struct or C++ struct and that could sound a bit ambiguous (not sure how much difference there is if any...).

Best regards,
Honza
Re: Dialog boxes : why struc instead of class ? [message #31632 is a reply to message #31624] Fri, 18 March 2011 15:01 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Ok, so nothing extraordinary !

It's just confusing for C++ developpers who learned to use class instead of struc, to be able to make an overridden class if necessary... But it's true that it's not very useful with the dialog boxes of an application !

Thanks for this explanation Smile

[Updated on: Fri, 18 March 2011 15:02]

Report message to a moderator

Re: Dialog boxes : why struc instead of class ? [message #31633 is a reply to message #31632] Fri, 18 March 2011 15:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jibe wrote on Fri, 18 March 2011 10:01


It's just confusing for C++ developpers who learned to use class instead of struc, to be able to make an overridden class if necessary... But it's true that it's not very useful with the dialog boxes of an application !



Actually, I am using mostly struct for dialogs in my "end-user" apps.

I guess that at the top layer of code, access protection is not that important.
Re: Dialog boxes : why struc instead of class ? [message #31636 is a reply to message #31624] Fri, 18 March 2011 15:26 Go to previous message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Its true that it's not important at the top layer of code. Just used to do always the same way... It's what we learned when studying C++, but it's just theory !
Previous Topic: Linux (no variants of project types)
Next Topic: Dialog box with some internal actions
Goto Forum:
  


Current Time: Mon May 06 08:05:17 CEST 2024

Total time taken to generate the page: 0.02498 seconds