Thread overview |
---|
July 05, 2013 Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Hi, I am new to D. I have no experience any language background. I have main function calling class "ABC" and class "ABC". I save separately like main.d and classABC.d. When I compile "dmd main.d classABC.d", it says "main.d(45); Error: undefined identifier ABC". How can i solve it? |
July 05, 2013 Re: Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | On Friday, 5 July 2013 at 20:08:18 UTC, Jaehunt wrote:
> Hi, I am new to D. I have no experience any language background.
>
> I have main function calling class "ABC" and class "ABC".
>
> I save separately like main.d and classABC.d.
>
> When I compile "dmd main.d classABC.d", it says "main.d(45);
> Error: undefined identifier ABC".
>
> How can i solve it?
Did you imported classABCd in main.d? Else it would be helpful if you post some code.
|
July 05, 2013 Re: Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | How to import classABC? Here is my main.d import std.stdio, std.conv, std.exception, std.math, std.random; void main() { ABC a = new ABC( a, b, c, d); ABC b = new ABC( e, f, g, h); ABC sum = a.sum( b); writeln( a); writeln( b); writeln( sum); } } |
July 05, 2013 Re: Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | On Friday, 5 July 2013 at 20:22:08 UTC, Jaehunt wrote:
> How to import classABC? Here is my main.d
>
> import std.stdio, std.conv, std.exception, std.math, std.random;
>
> void main() {
>
> ABC a = new ABC( a, b, c, d);
> ABC b = new ABC( e, f, g, h);
>
> ABC sum = a.sum( b);
>
> writeln( a);
> writeln( b);
> writeln( sum);
>
> }
>
> }
E.g. with
import classABC;
|
July 05, 2013 Re: Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | Thank you for replying. I added import classABC; on second line in main.d and compiled. Now it says main.d(2): Error:module classABC is in file 'classABC.d' which cannot be read. |
July 05, 2013 Re: Compile main and class source. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | On Friday, 5 July 2013 at 20:29:54 UTC, Jaehunt wrote:
> Thank you for replying.
>
> I added import classABC; on second line in main.d and compiled.
>
> Now it says main.d(2): Error:module classABC is in file 'classABC.d' which cannot be read.
File name was not 'classABC. Sorry!
I SOLVED IT.
THANKS A LOT
|
Copyright © 1999-2021 by the D Language Foundation