ECMA Doc 8.8.4 Error

  • Thread starter Thread starter Don Kim
  • Start date Start date
D

Don Kim

When I try to compile the following from the ECMA Docs:

#using <mscorlib.dll>
using namespace System;

public value class point {
int Xor;
int Yor;

public:
property int X {
int get() { return Xor; }
void set(int value) { Xor = value; }
}
property int Y {
int get() { return Yor; }
void set(int value) { Yor = value; }
}

point() {
move(0, 0);
}

point (int x, int y) {
move(x, y);
}

void move(int x, int y) {
X = x; //absolute move
Y = y;
}

void translate(int x, int y) {
X += x;
Y += y;
}
};

int main()
{
point p1;

p1.X = 10;
p1.Y = 5;
p1.move(5, 7);
point p2(9, 1);
p2.translate(-4, 12);
}


I get this error:

8_8_4.cpp(18) : error C3417: 'point::point' : value types cannot contain
user-defined special member functions

Anyone know why?

-Don Kim
 
Special member functions like default constructors, copy constructors and
destructors are not allowed on value classes.
SMF support has been withdrawn. IMO the example was written before the
withdrawal of the default constructor.
Maybe you could report this issue on
http://lab.msdn.microsoft.com/productfeedback

Willy.
 
Willy Denoyette said:
Special member functions like default constructors, copy constructors and
destructors are not allowed on value classes.
SMF support has been withdrawn. IMO the example was written before the
withdrawal of the default constructor.
Maybe you could report this issue on
http://lab.msdn.microsoft.com/productfeedback

You seem correct. I removed the default constructor point(), and the
program compiled. I went ahead and reported to the link above. Thanks.

- Don Kim
 
Back
Top