I recently tried to learn about the defaulted and deleted functions in C++ 11 and i wrote the sample code below. When I try to run it says :
error C2065: ‘default’ : undeclared identifier
the Code :
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct A
{
int age;
A(int x): age(x){};
A() = default;
};
int _tmain(int argc, _TCHAR* argv[])
{
A test(10);
cout << test.age << endl;
return 0;
}
It seems that you are using Microsoft Visual Studio. I’m sorry but the Microsoft compiler doesn’t allow this new syntax even in the new version VC11.
Check the list of the available features here. You will see that Defaulted and deleted functions isn’t yet available.