C ++ 11 Delegating Constructors in Visual Studio 2012

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 am getting is:

error C2437: 'ErrorReportDlg': already initialized

What am I doing wrong? Thanks!

+4
source share
1 answer

According to MSDN , VS 2012 does not support delegation of constructors out of the box.

When installing November 2012 CTP, you get delegating constructors (and a bunch of other C ++ 11 features) (technical review of the compiler). After installation, switch your project to use CTP as a toolbox (via Project properties ), and you will install.

+6
source

All Articles