[Issue 12346] Instantiating class with a private constructor results in a runtime error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 11 05:05:53 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12346
Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |andrej.mitrovich at gmail.com
Resolution| |INVALID
--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-03-11 05:05:46 PDT ---
1: You're not instantiating the class. You need to use 'new' to instantiate it,
via:
-----
class TestClass
{
private this() {}
uint value;
}
void main()
{
TestClass x = new TestClass();
x.value = 10;
}
-----
2: This is a reference, not instantiation, it cannot be an error even if the
reference type is of an abstract class:
-----
abstract class AC
{
private this() {}
}
void main()
{
AC ac; // allowed
}
-----
3: Private symbols are visible and usable in the entire module they're defined
in.
Please read the documentation before filing bugs, or use the D forums[1] if you
have questions or want to learn about D.
[1] : http://forum.dlang.org/group/digitalmars.D.learn
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list