#include "stdafx.h"

using namespace System;

value struct Point
{
public:
    int x, y;
    Point() {
        x = 0;
        y = 0;
    }
};

Problem of struct default constructor in vc++2005 beta1란 토론이 있는데, 위의 코드를 실행하니까 Error 1 error C3417: 'Point :: Point' : value types cannot contain user-defined special member functions란 오류가 뜨더란 이야기다. 별 이야기는 아니니까 바로 결론을 말하자면, 이건 CLR 명세에 따른 오류다. 값 타입은 무조건 0으로 초기화되며 사용자 정의 생성자를 갖지 못한다. 만약 생성자 역할을 해줄 뭔가가 필요하다면 이렇게 하면 된다.

#include "stdafx.h"

using namespace System;

value struct Point
{
public:
    int x, y;
    Point New() {
        Point point;
        point.x = 1;        
        point.y = 2;
        return point;
    }
};

어라, 정리해놓고 보니 C#쪽에선 사용자 정의 생성자가 들어가도 되네. C++/CLI에만 해당하는 이야긴가? 좀더 자세히 알아봐야겠다.