Cannot pass by reference
Jeroen Bollen
jbinero at gmail.com
Sat Nov 16 06:08:08 PST 2013
I cannot seem to pass values to functions by referece.
----------------------------------------------------------------------------------
@safe public nothrow this(ref Socket socket) {
// Inside class modulename.classname
this.socket = socket;
}
----------------------------------------------------------------------------------
void main() {
auto variablename = new modulename.classname(
cast(Socket) new TcpSocket() // main.d line 5
);
}
----------------------------------------------------------------------------------
This code gives me a compile error:
main.d(5): Error: constructor modulename.classname.this (ref
Socket socket) is not callable using argument types (Socket)
main.d(5): Error: no constructor for classname
Why is that?
More information about the Digitalmars-d-learn
mailing list