Jump to content
  • Advertisement
Sign in to follow this  
cpp forever

Unity Overriding constructor

This topic is 4508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!