class constructor

gedaiu szabobogdan at yahoo.com
Sat Apr 13 01:33:25 PDT 2013


On Saturday, 13 April 2013 at 07:57:30 UTC, Nicolas Guillemot 
wrote:
> Classes are instanciated with new, structs are not. The 
> following program compiles:
>
> class A {
> 	int myVal;
>
> 	this(int val) {
> 		myVal = val;
> 	}
> }
>
> struct B {
> 	int myVal;
>
> 	this(int val) {
> 		myVal = val;
> 	}
> }
>
> void main() {
> 	A myA = new A(8);
>
> 	B myB = 8;
> }

Thanks!


More information about the Digitalmars-d-learn mailing list