Sign in to follow this  
cpp forever

Unity Overriding constructor

Recommended Posts

Hi, community!! Happy to be back! I have the following problem. I want to extend ConfDialog class from Dialog class. Doing smth wrong possibly: Part of Dialog class.
  Dialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent) {
    // Call to DlgProc() with hwnd = NULL will save pointer to this object in
    // DlgProc()-s' static variable.
    DlgProc(NULL, 0, 0, (LPARAM)this);
    
    CreateDialog(hInstance, lpTemplate, hWndParent, DlgProc);
  }

  ~Dialog() {
    SetWindowLongPtr(hWnd, GWL_USERDATA, (LONG_PTR)NULL);
  }


And here goes ConfDialog class (it simply has nothing):
class ConfDialog : public Dialog {
public:
};


When I want to create a ConfDialog object:
  // Create configuration window.
  conf_dialog = new ConfDialog(
    plugin.hDllInstance,
    MAKEINTRESOURCE(IDD_CONF),
    plugin.hwndParent
  );


MSVC 8.0 tells me that
Error	1	error C2660: 'ConfDialog::ConfDialog' : function does not take 3 arguments		
. Thanx.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
try this:

class ConfDialog : public Dialog {
public:
ConfDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent) {
Dialog(hInstance, lpTemplate, hWndParent);
}
};

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
try this:
*** Source Snippet Removed ***


Almost:

class ConfDialog : public Dialog {
public:
ConfDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent)
: Dialog(hInstance, lpTemplate, hWndParent)
{
}
};

Share this post


Link to post
Share on other sites
The 2nd reply is correct.

The reason you have to do that is is that constructors aren't inherited like normal functions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this