Results 1 to 4 of 4

Thread: difference between proxies from class and from interface

  1. #1
    kovacm is offline Registered User
    Name: Michal Kovac
    Organization: Charles University in Prague
    Project: Ferda Data Mining
    Join Date
    Jan 2005
    Posts
    60

    difference between proxies from class and from interface

    Hi,

    Is possible something like:

    Code:
    class C {
      string str;
      nonmutating string getString();
    };
    
    interface I extends C {
    };
    
    class D implements C {
    };
    Can I create interface by extending "interface from class" C? and the same - if I can create class D implementing only "interface from class" C?

    I know that in normal languages it is not possible, but there, how I see ICE works, if I pass class by reference it is the same like I pass "interface from class"... and because it is only interface, I would like to implement more these interfaces in one.

  2. #2
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    A class can implement multiple interfaces and in addition extend a single class. An interface can extend multiple other interfaces, but not classes. No other inheritance relationships are possible. Slice follows the Java rules in this respect. If Slice were to support more inheritance relationships, such as multiple class inheritance, a language mapping from Slice to Java would not be possible, or at least very complicated.

  3. #3
    kovacm is offline Registered User
    Name: Michal Kovac
    Organization: Charles University in Prague
    Project: Ferda Data Mining
    Join Date
    Jan 2005
    Posts
    60
    Thank you,

    Quote Originally Posted by marc
    If Slice were to support more inheritance relationships, such as multiple class inheritance, a language mapping from Slice to Java would not be possible, or at least very complicated.
    but I would not like to use multiple class inheritace...

    My qouestion was there because I thougth that

    Code:
    class C {
      string a;
      nonmutating string getA();
    };
    is somehow implemented like:

    Code:
    interface C {
      nonmutating string getA();
    };
    
    class C implements C {
      string a;
    };
    and when C is used for passing by reference, it is that interface, if it is passed by value, it is that class.

    And I would like to implement only more these interfaces (thats why I used word "implements" and not "extends").

    On other hand if it is not possible, it is OK.

    thank you,
    Michal

  4. #4
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Quote Originally Posted by kovacm
    Is possible something like:

    Code:
    class C {
      string str;
      nonmutating string getString();
    };
    
    interface I extends C {
    };
    
    class D implements C {
    };
    Can I create interface by extending "interface from class" C? and the same - if I can create class D implementing only "interface from class" C?
    There is no specific mechanism for inheriting "just the interface part" of a class, and it is illegal for an interface to derive from a class. But you can rearrange the Slice as follows to get the same effect:

    Code:
    interface COps {
      nonmutating string getString();
    };
    
    class C implements COps {
      string str;
    };
    
    interface I extends COps {
    };
    
    class D implements COps {
    };
    Cheers,

    Michi.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Common interface for objects and proxies
    By oag in forum Help Center
    Replies: 3
    Last Post: 05-11-2010, 09:13 PM
  2. Ice-3.1.0 - slice2cpp - interface seq in class
    By StuartA in forum Bug Reports
    Replies: 2
    Last Post: 07-15-2006, 08:15 PM
  3. Replies: 12
    Last Post: 03-24-2006, 10:38 AM
  4. Replies: 4
    Last Post: 12-09-2004, 04:53 PM
  5. Class/Interface Confusion with IcePack
    By amrufon in forum Help Center
    Replies: 2
    Last Post: 07-14-2004, 05:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •