Home Help Center

Class inheritance problem

My problem is that I want to write a ChannelBase.ice which contains a
ChannelBase.ice
module MyNameSpace
{
class ChannelBase
{
void myOperation();
}
}

I generate a ChannelBase.cpp, and create a simple helper C functions to create a proxy to a ChannelBase server, and call the myOperation() on it. For this C file I need the ChannelBase.h and ChannelBase.obj.

Then I want to extend the ChannelBase class adding a new operation:

AdvChannelBase.ice
module MyNameSpace
{
class ChannelBase
{
void myOperation();
}
class AdvChannel extends ChannelBase
{
void myOtherOperation();
}
}

I want to create another helper C function to create an AdvChannel proxy and call the myOtherOperation() on it.

Compiling them generates 4 .obj files. That is easy. But I link these 4
obj-s together, the linker says, that (for example) the myOperation already defined ...

What is solution?

(sorry for my terrible english. I am a little bit tired now :( I hope the problem is clear... )

Comments

  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    Re: Class inheritance problem
    Originally posted by aroan
    My problem is that I want to write a ChannelBase.ice which contains a

    ChannelBase.ice
    module MyNameSpace
    {
    class ChannelBase
    {
    void myOperation();
    }
    }

    I generate a ChannelBase.cpp, and create a simple helper C functions to create a proxy to a ChannelBase server, and call the myOperation() on it. For this C file I need the ChannelBase.h and ChannelBase.obj.

    Then I want to extend the ChannelBase class adding a new operation:

    AdvChannelBase.ice
    module MyNameSpace
    {
    class ChannelBase
    {
    void myOperation();
    }
    class AdvChannel extends ChannelBase
    {
    void myOtherOperation();
    }
    }

    I want to create another helper C function to create an AdvChannel proxy and call the myOtherOperation() on it.

    Compiling them generates 4 .obj files. That is easy. But I link these 4
    obj-s together, the linker says, that (for example) the myOperation already defined ...

    What is solution?

    (sorry for my terrible english. I am a little bit tired now :( I hope the problem is clear... )

    You should #include ChannelBase.ice in AdvChannelBase.ice instead of duplicating the definition of ChannelBase.

    Regards, Matthew
  • aroanaroan Member
    When I try to write

    #include <Channel.ice>
    module MyNameSpace
    {
    class AdvChannel extends ChannelBase
    {
    void myOtherOperation();
    }
    }
    ... I got "no include path in which to find Channel.ICE". It is odd, cause this file is in the current directory.

    when I use "slice2cpp -IDIR .\ AdvChannel.ICE" it says "input files must end with .ice"

    Any idea?
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    If the included file is in the current directory, then you need to specify

    slice2cpp -I. AdvChannel.ice

    The DIR in the usage instructions for the -IDIR option is supposed to be replaced with a directory, as I've shown above.

    - Mark
  • aroanaroan Member
    Aham. That's working now. May be the form -I<DIR> would be more understable. And it is not clear why the actual directory is not in the include directory list by default. But after that it was my mistake :-)

    Thank you for your help.
Sign In or Register to comment.