<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
I had a look at <a class="moz-txt-link-freetext" href="http://www.digitalmars.com/d/2.0/class.html#ConstClass">http://www.digitalmars.com/d/2.0/class.html#ConstClass</a>.<br>
Does this mean that I should be able to write something like :<br>
<blockquote><tt>module test;<br>
  <br>
invariant class Thing {<br>
    private int _field;<br>
  <br>
    this(int field) {<br>
        _field = field;<br>
    }<br>
  <br>
    int field() {<br>
        return _field;<br>
    }<br>
}</tt><br>
</blockquote>
?<br>
It doesn't compile:<br>
<blockquote><tt>Error: cannot implicitly convert expression (this) of
type invariant(Thing) to test.Thing</tt><br>
</blockquote>
The error doesn't mention any line. I don't undestand it. <br>
I thought it would be a way of saying that instances of a class are
always const or immutable.<br>
Sorry if I said something stupid <span class="moz-smiley-s1"><span>
:-)  </span></span>...<br>
<br>
Nicolas<br>
</body>
</html>