|
Hi
Maybe wrong forum but here goes anyway...I was asked 5 questions in a telephone interview. Anybody give their thinking on the following two....
1) Why would passing a parameter into a copy constructor by value be a waste of time
2) When would you use private inheritance
if you're still reading...
3) 3 main differences between a class and a struct. (I said classes are private by default, structs are public. Structs are value based, classes are referenced base (read that somewhere), classes can use polymorphism, late binding etc). Anywhere near?
Thanks for your time.;P
Regards
Angel
===========================================================
The sooner you fall behind, the longer you have to catch up
|
|
|
|
|
Angel1058 wrote:
2) When would you use private inheritance
When you need the public and protected members of the base class to be private in the derived class. In the past 11 years, I've never had the need.
Angel1058 wrote:
3) 3 main differences between a class and a struct.
I only know of one main one. While others might exist, they are probably insignificant in comparison.
Angel1058 wrote:
...classes can use polymorphism
So can struct s:
struct Auto
{
public:
virtual void Engine(){}
};
struct Car : public Auto
{
public:
void Engine(){}
};
struct Truck : public Auto
{
public:
void Engine(){}
};
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
2) When would you use private inheritance
When you need the public and protected members of the base class to be private in the derived class. In the past 11 years, I've never had the need.
I answered the same, but said all members to be private, which is effectively what you're saying. He wasn't happy - he wanted an example of when you would use private inheritance!
DavidCrow wrote:
3) 3 main differences between a class and a struct.
I only know of one main one. While others might exist, they are probably insignificant in comparison.
What is your main one?
DavidCrow wrote:
...classes can use polymorphism
So can structs:
Didn't know that!
Thanks for your time.
Regards
Angel.
===========================================================
The sooner you fall behind, the longer you have to catch up
|
|
|
|
|
Angel1058 wrote:
What is your main one?
The same one you noted.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I have an application where the mainframe consists of a list control in the view. I update and display values here. On Exiting the application I need to do some stuff here.
I tried writing a function that handles the WM_CLOSE message... the function gets called for the mainframe, but not for the view. Looking into the MainFrame, I don't see an instance of the view being created and consequently can't invoke the function directly. what should i do?
HelpWanted!
|
|
|
|
|
help_wanted wrote:
On Exiting the application I need to do some stuff here.
Have you considered the app's ExitInstance() method?
help_wanted wrote:
Looking into the MainFrame, I don't see an instance of the view being created...
Probably because it is not created in the frame. The document, frame and view are all created in the app's InitInstance() method.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Have you considered the app's ExitInstance() method?
Is this called without destroying the view etc?
DavidCrow wrote:
Probably because it is not created in the frame. The document, frame and view are all created in the app's InitInstance() method.
Yeah it is. Thanks!
|
|
|
|
|
help_wanted wrote:
Is this called without destroying the view etc?
See here.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Situation is quite ordinary: I have a main window class(for example derived from CDialog) and call a modal dialog from it's method. Choosing some settings from within it affects data of the main window class. So what is the most elegant way to establish communication between these two dialogs? How is it implemented more often in practice? One solution I see is to pass a pointer of the main class as an argument to constructor or any other method of this "settings" dialog and manipulate all tha data directly. Or I can save all changes in some kind of mediums such as global variables or object with static members and then when this secondary dialog is about to be destroyed it sends message to the main window class in order to read data from these transitional variables and update it's data. Or perhaps there is another way to do it?
|
|
|
|
|
Something like:
CMainDlg::OnButtonClick()
{
CChildDlg dlg(&some_data_here);
if (dlg.DoModal() == IDOK)
...
} If you don't want to do it via the constructor, try:
CMainDlg::OnButtonClick()
{
CChildDlg dlg;
dlg.m_some_data = m_some_data;
if (dlg.DoModal() == IDOK)
m_some_data = dlg.m_some_data;
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ok, but, if we do the second method, you consider that DoModal() returns IDOK before destroying the CChildDlg . Don't DoModal() return it value when the dialog's closed ?
what about passing to the CChildDlg directly a pointer to the "parent dialog" instead of a pointer to a some data ?
thx for your answer
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
DoModal() returns IDOK before destroying the CChildDlg . Don't DoModal() return it value when the dialog's closed ?
The CChildDlg object exists after the dialog it was associated with has been destroyed. This is why you can access CChildDlg member variables after the dialog has been dismissed.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Imho, the most elegant way would be to package your data in an object that exists in your main window, and pass that object to the modal dialog.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Hi,
Ive been learning how to use DirectInput for a small Win32 game Im making. Ive been looking at the article
http://www.gamedev.net/reference/articles/article607.asp
to get started.
I type in, as stated in the article, the function
DirectInputCreate. It looks like this:
DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &lpdi, NULL);
Yet whenever I try to compile in C++ 6 I get the error:
'DirectInputCreate' : undeclared identifier
After searching the net I found the website:
http://www.mvps.org/directx/faq/directx_general_issues.htm#dinputcreate
It states:
"Compiling code for previous versions of DirectInput under DirectX 8, you must define a constant specifying the required version support prior to including dinput.h. Define DIRECTINPUT_VERSION to be equal to 0x300, 0x0500, or 0x0700"
I tried this and I get the same error message. This is really getting frustrating. Please help!
By the way I have definately included the DINPUT.H file.
Thanks for any help you can give!
|
|
|
|
|
this may not be the same thing, but in some Direct3D books I've read stuff in, it'll have the name as DirectInputCreate() when it's really something like DirectInputCreate8() (notice the '8'), or --9 or whatever version. I don't know if this is the problem but for whatever version of DirectX you're using, try looking up that same function name with a number appended to the end.
Other than that, the only other thing I can think of is that you didn't link one of the appropriate libraries. For your project properties, for additional include folders, specify the appropriate folder for your directx stuff, and move it to the top of the list. For additional library directories, do the same thing for your [directx path]/lib folder. Hope any of this helped
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
what version of DirectX are you using? I have 9 and I just looked in my help files for that function, and this is what I came up with: notice they have the '8' stuck in the middle of the function name.
<big>DirectInput8Create Function</big>--------------------------------------------------------------------------------
Creates a Microsoft® DirectInput® object and returns an IDirectInput8 or later interface.
Syntax
HRESULT WINAPI DirectInput8Create( HINSTANCE hinst,
DWORD dwVersion,
REFIID riidltf,
LPVOID *ppvOut,
LPUNKNOWN punkOuter
);
Parameters
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
I have it working! Im not sure what Ive done but my app compiled and worked.
I think I did the following:
#include <dinput.h>
#define DIRECTINPUT_VERSION 0x0700
rather than
#define DIRECTINPUT_VERSION 0x0700
#include <dinput.h>
DINPUT.H has its own DIRECTINPUT_VERSION defined and so I needed to define my own before I included the DINPUT.H file. Sorry for wasting your time on such a mistake.
As for the DirectInput8Create() function it seems that this is a improved function introduced in DirectX 8. This might explain why the other function doesnt work properly with DirectX 9. Thanks for bringing it to my attention. Im going to ditch the article I was using as it seems as though it was made for much older DirectX versions and research these new DirectX 8 functions.
Thanks for your help!
|
|
|
|
|
Trying to compose a MDI GUI like this, But still not yet figure out how to after a few days. Can anyone hlep? great thanks.
The GUI carries these features:
1. is a MDI.
2. a panel on the left side, which works like 'Search' panel in Win2K IE:
2-1. able to hide.
2-2. remain last setting and input when hide and re-show.
2-3. not float-able.
2-4. resizable.
First I tried to place a splitter into Client Window in MDI, but failed. Then I tried to use resizable controlbar, but can not satisfy requirement 2-3.
Any advices or ideas will be appreciated.
|
|
|
|
|
First I tried to place a splitter into Client Window in MDI,
why ?
I would do it with a dynamic splitter window, seems that it fits the required behaviour.
create a CSplitter, and put in either a formview or a child dialog.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thank you, Maximilien.
Using MDI because that there will be many different child windows in the right side, and they will are abled to be organized in any layouts which users prefer.
So a splitter may not fit.
|
|
|
|
|
you want that window/pane attached to what ? the main frame or the MDI child windows ?
if it's the main frame, I think that using an undockable toolbar/dialogbar/sizablebar is the way to go, if the mdi child frame windows, I stand by the use of a splitter window.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
jpup wrote:
1. is a MDI.
This is one of the choices offered by AppWizard.
jpup wrote:
2. a panel on the left side, which works like 'Search' panel in Win2K IE:
You need to add a CSplitterWnd object to the CMDIChildWnd -derived class. Then override the OnCreateClient() member function. Call CreateStatic() from within OnCreateClient() . You might also need to make two calls to CreateView() .
jpup wrote:
2-2. remain last setting and input when hide and re-show.
Nothing special required for this.
jpup wrote:
2-3. not float-able.
Outside the context of a toolbar, I'm not sure what you mean by this.
jpup wrote:
2-4. resizable.
Nothing special required for this.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you, DavidCrow.
Let me make it clear the requirement.
1. is a MDI: the 'panel' will locate in the left-hand side of the main window, while ClientWindow of MDI will locate in the right-hand side. Therefore, all child frame will be working in the left-hand side of the main window. So using splitter may not fit.
2-3 not float-able: because I try to use controlbar to build up the panel. but failed to make it un-float-able. Then I addd this item as a reference.
|
|
|
|
|
Hai,
I'm new to vc++ win32...i am trying to read and write to serial port COM1.
I know we can do this by createfile and read and writefile fns..but i am not sure about the flags and how to set buffer values..and what other funcs i need to do..suppose i want to write say "hello" to com1 and get the acknowledge "hi" from it...can any one help me with the code exactly how to do it..
thanks a lot.
|
|
|
|