class Car<br />
int speed;<br />
doulbe engineSize;<br />
I persoanlly dislike code like this. I tend to make all data members private and provide inlined get and set methods where appropriate. The main reason I like the get and set methods is its easier to debug code as you can put a break point in the set method for example and catch every change to the value. Also it prevents people taking the address of these variables and manipulating them through pointers which can also be hard to track down in a large project.
Im interested to hear the opinions of others on the use of public data members or getter and setter methods
In my opinion it depends about what is being done. In my studies final project I was using GET and SET everywhere, but not with numbers or easy variables. I was using them with objects that holded more than hundred parameters (its sizeof (myObject) in some points were in KB). Because of that when I was searching elements of the third hierarchy (it means go in a collection of elements, where every element has a collections of other elements, and then search for the concrete parameter inside another collection), the program was f***ing slow and needed a lot of resources to get the object between classes.
I change it to public and worked with pointers/references and then all was fine.
I like to use Get and Set, but sometimes is impossible.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Inline getters and setters should work just as fast as direct access.
An advantage of getters and setters is you can change the implementation without
having to change code anywhere else. For example, if in the future you need to calculate
the "speed" member on the fly, all you'd have to do is implement that functionality in the getter
method. All code that uses it stays the same.
Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!
I am trying to get and set the following information from File/Open save dialog of Microsoft Office 2000/2003/2007
1.Retrieve the currently displayed/selected folder path and also the file name that is selected if any.
2. Retrieve the selected file path, when the user clicks the open or save button.
3.Set a pre-defined string path within the file-name combo box.
I have been able to do the above task in case of File Open/Save common controls dialog(used by WordPad ,Notepad,
Acrobat Reader etc.) by using the dialog functions depicted in MSDN. But it is not working with Microsoft Office Dialog and I have found no MSDN documentation that depicts the internal messages of Microsoft Office Dialogs.
Microsoft Office doesn't use the common dialog for file open/save AFAIK.
The Office dialogs may well be undocumented. From our point of view, the
MS Office suite of applications are proprietary 3rd-party applications, not part of the
operating system, so there's no reason the dialogs and their functionality should be
You may get a reply here from someone with the info you need.
In the meantime, here's a couple links you may or may not have been to already:
so then the "regular dll that uses MFC" can't contain classes? for instance, if i wanted to put a dialog and associated functions in a dll, i would use the extension dll whereas if i were only creating functions that say, operated on a CString, i could do that in a "regular dll that uses MFC" ?
so then the "regular dll that uses MFC" can't contain classes?
it can contain them, sure. you can even export them: (for example).
but if you want to export C++ classes, you'll really should use an MFC extension DLL. most importantly, this ensures that the app and the DLL are using the same heap for memory allocation - don't want to pass a CString which has allocated memory into a DLL which is looking at a different heap...
or, as MS puts it: "If you need to pass an MFC or MFC-derived object pointer to or from an MFC DLL, the DLL should be an extension DLL."
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
::GetClassLong(GetSafeHwnd(), GCL_STYLE) | CS_DROPSHADOW/*0x00020000*/
return TRUE; // return TRUE unless you set the focus to a control
Note that CS_DROPSHADOW requires a Windows version >= XP.
Note that after this code is run ALL dialogs will have shadows!
I'm implementing an simulator and the user interacts with an image reflected in a mirror. How can I do this reflection, how can I flip or change this 3d world?
I'm using C++ language with Opengl and OpenHaptics (Phantom Omni library).