complex.d:
module complex;
class Complex
{
int real;
int imaginary;
}
Complex add( Complex A, Complex B )
{
Complex C;
C.real = A.real + B.real;
C.imaginary = A.imaginary + B.imaginary;
return C;
}
Complex subtract( Complex A, Complex B )
{
Complex C;
C.real = A.real - B.real;
C.imaginary = A.imaginary - B.imaginary;
return C;
}
void showValue( Complex A )
{
writeln( "%d + %di", A.real, A.imaginary );
}
main.d:
module main;
import std.stdio;
import complex;
void main()
{
Complex A;
Complex B;
A.real = 5;
A.imaginary = 6;
B.real = 2;
B.imaginary = 9;
Complex C;
Complex D;
C = add( A, B );
D = subtract( A, B)/>;
showValues(A);
showValues(B)/>;
showValues(C);
showValues(D);
}
When I attempt to compile main.d on the Ubuntu command prompt gdc compiler I recieve the following two errors:
main.d:13: identifier expected following '.', not 'real'
main.d:16: identifier expected following '.', not 'real'
Is the compiler simply not reading from the complex.d module? What would be the correct way to import the complex.d module?

New Topic/Question
Reply



MultiQuote







|