4

I am trying to use delegating constructors in Visual Studio 2012. The following code compiles in Xcode 4.6 but not in Visual Studio 2012:

In the .h file

class ErrorReportDlg : public QDialog
{

public:
    ErrorReportDlg(OwlExceptionPtr ex, QWidget *parent);
    ErrorReportDlg(QWidget *parent);

    virtual ~ErrorReportDlg();
}

In the .cpp file

// FWIW, OwlExceptionPtr is 
// typdef boost::shared_ptr<OwlException> OwlExceptionPtr

ErrorReportDlg::ErrorReportDlg(OwlExceptionPtr ex, QWidget *parent)
    : QDialog(parent),
    _error(ex)
{
    // stuff
}

ErrorReportDlg::ErrorReportDlg(QWidget *parent)
    : ErrorReportDlg(OwlExceptionPtr(), parent) // <--- error here
{
    // do nothing
}

The error I'm getting is:

error C2437: 'ErrorReportDlg' : already initialized

What am I doing wrong? Thank you!

Addy
  • 2,414
  • 1
  • 23
  • 43

1 Answers1

6

As per MSDN, VS 2012 doesn't support delegating constructors out of the box.

You get delegating constructors (and a bunch of other C++11 features) when you install the November 2012 CTP (Compiler Technical Preview). After installing, switch your project to use the CTP as its toolset (via Project properties), and you're set.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455