Thread overview
import `Class` is used as a type
Sep 10, 2022
Injeckt
Sep 10, 2022
H. S. Teoh
Sep 10, 2022
Injeckt
September 10, 2022

I'm trying use classes in my project, but when i'm try inherit class, I get error:

    Error: import `Server.Console` is used as a type

Server.d:

    module Server;

    import std.string;
    import core.sys.windows.windows;
    import Console;

    class Server : Console {
        this(HANDLE hIn, HANDLE hOut) {
            super(hIn, hOut);
        }

        ~this() {
            // Delete object;
        }
    }

Console.d:

    module Console;

    import std.string;
    import core.sys.windows.windows;

    class Console {
        public:
            HANDLE hIn;
            HANDLE hOut;

        this(HANDLE hIn, HANDLE hOut) {
            this.hIn = hIn;
            this.hOut = hOut;
        }
    }

What does it mean?

September 10, 2022
On Sat, Sep 10, 2022 at 04:59:50PM +0000, Injeckt via Digitalmars-d-learn wrote:
> I'm trying use classes in my project, but when i'm try inherit class, I get error:
> 
>         Error: import `Server.Console` is used as a type
[...]

Don't name the module the same thing as the class.  Rename it to, say, `console`, so that it wouldn't clash with the class name `Console`.


T

-- 
IBM = I Blame Microsoft
September 10, 2022
On Saturday, 10 September 2022 at 17:20:29 UTC, H. S. Teoh wrote:
> On Sat, Sep 10, 2022 at 04:59:50PM +0000, Injeckt via Digitalmars-d-learn wrote:
>> I'm trying use classes in my project, but when i'm try inherit class, I get error:
>> 
>>         Error: import `Server.Console` is used as a type
> [...]
>
> Don't name the module the same thing as the class.  Rename it to, say, `console`, so that it wouldn't clash with the class name `Console`.
>
>
> T

Thank you!