A constructor not marked public can be accessed by code within the same 
package. So here the problem is that you put the class in its own 
package. Hence non-public constructors are not visible to other classes 
outside that package (see also the discussion on protected modifier for 
an exception to this, as in Java).

On 10/27/14, 2:14 PM, Michael Dietrich wrote:
> Hello,
>
> I'm not sure if it's either a mistake in the Specification or I did
> something wrong.
> On page 97 of the Language Specification there is the description of
> constructors. The example is the following:
>
> class C {
>       public val a : Long;
>       def this(b : Long) { a = b; }
>       def this() { a = 10; }
>       /*
>       ...
>       */
> }
>
> So I tried to implement a constructor for my own class as well. I
> don't know if this fact is important but this class is in an own
> package.
> I imported it into my main-file and tried to construct an instance if
> this class. The compiler returned the error message "Constructor is
> inacessible" on the line where I wanted to use the constructor.
>
> As a possible soluton I changed the constructor's header into "public
> def this() {/*...*/} which seems to work.
>
> My question is: Is the "public" in the Language Spec missing or was it
> my mistake?
>
> bye
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>


------------------------------------------------------------------------------
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to