class inherit class A _and_ class B

class inherit class A _and_ class B

Post by Hans Saure » Wed, 29 Nov 2000 04:00:00



Hi all,
we need a class that inherits two other classes. But there is a big
difficulty, so I describe a little further. There are two classes let us
call them C1 and C2. C1 is inherited by A1, C2 by A2. Both classes (A1 and
A2) need more methods, which lay in another class (let us say Z). Therefore
A1 inherits C1 and Z, A2 inherits C2 and Z, but Z does _not_ inherit any
other class, even because they are different. We use VO 2.5b-1. Is this
possible and if yes, how can we implement it?

Regards

Hans Sauren

 
 
 

class inherit class A _and_ class B

Post by Willie Moor » Wed, 29 Nov 2000 04:00:00


Hans,

Unless something has changed, VO does not support multible inheritance.

Regards,

Willie


Quote:> Hi all,
> we need a class that inherits two other classes. But there is a big
> difficulty, so I describe a little further. There are two classes let us
> call them C1 and C2. C1 is inherited by A1, C2 by A2. Both classes (A1 and
> A2) need more methods, which lay in another class (let us say Z).
Therefore
> A1 inherits C1 and Z, A2 inherits C2 and Z, but Z does _not_ inherit any
> other class, even because they are different. We use VO 2.5b-1. Is this
> possible and if yes, how can we implement it?

> Regards

> Hans Sauren


 
 
 

class inherit class A _and_ class B

Post by Greg Garz » Wed, 29 Nov 2000 04:00:00


Hans,

I don't know how your Class Z is designed, but you might try something like
this:

Class A1 Inherit Class C1
    Protect oZContainer AS Z

Method Init( ) Class A1
    Self:oZContainer := Z{ }
    Return Self

Method SampleFunction( ) Class A1
    Self:oZContainer:ZClassMethod1( )
    Self:oZContainer:ZClassMethod2( )

You haven't exactly inherited from Class Z, but you've instantiated a
Container in Class A1 which holds an instance of Class Z.  You can then call
methods of Class Z.  As I said however, depending on the design of Class Z,
this may not be possible for you.

HTH,

Greg

 
 
 

class inherit class A _and_ class B

Post by Malcolm Gra » Wed, 29 Nov 2000 04:00:00



Quote:> Hi all,
> we need a class that inherits two other classes. But there is a big
> difficulty, so I describe a little further. There are two classes let us
> call them C1 and C2. C1 is inherited by A1, C2 by A2. Both classes (A1 and
> A2) need more methods, which lay in another class (let us say Z).
Therefore
> A1 inherits C1 and Z, A2 inherits C2 and Z, but Z does _not_ inherit any
> other class, even because they are different. We use VO 2.5b-1. Is this
> possible and if yes, how can we implement it?

VO does not allow multiple inheritance.

As I see it you have a number of options.
a) make C1 and C2 inherit from Z
b) Contain a Z in A1 and A2 and forward using NoMethod, NoIvarGet etc
You have not said whether Z has any members or whether it only has methods.
Are you trying to inherit the interface of the implementation?
Equally you have not said whether A1 or A2 need to override any of the
methods in Z

If you are feeling brave I suspect you could use the information in
Rod's articules in SDT to modify A1 and A2 at run time to point to the
methods of Z,
but I would not recommend that for "normal" use.

 
 
 

class inherit class A _and_ class B

Post by FDW » Wed, 29 Nov 2000 04:00:00


It's called delegation and works fine for me ;-)

Frans


Quote:> Hans,

> I don't know how your Class Z is designed, but you might try something
like
> this:

> Class A1 Inherit Class C1
>     Protect oZContainer AS Z

> Method Init( ) Class A1
>     Self:oZContainer := Z{ }
>     Return Self

> Method SampleFunction( ) Class A1
>     Self:oZContainer:ZClassMethod1( )
>     Self:oZContainer:ZClassMethod2( )

> You haven't exactly inherited from Class Z, but you've instantiated a
> Container in Class A1 which holds an instance of Class Z.  You can then
call
> methods of Class Z.  As I said however, depending on the design of Class
Z,
> this may not be possible for you.

> HTH,

> Greg

 
 
 

class inherit class A _and_ class B

Post by Andrew Harve » Thu, 30 Nov 2000 04:00:00


Quote:> Method SampleFunction( ) Class A1
>     Self:oZContainer:ZClassMethod1( )
>     Self:oZContainer:ZClassMethod2( )

Likewise you could simple write a new method for class A1 that calls the Z
Class methods that you require i.e..
METHOD Method1() CLASS A1
RETURN Self:oZContainer:Method1()

of course you would have to write a similar method for class A2.

Andrew


Quote:> Hans,

> I don't know how your Class Z is designed, but you might try something
like
> this:

> Class A1 Inherit Class C1
>     Protect oZContainer AS Z

> Method Init( ) Class A1
>     Self:oZContainer := Z{ }
>     Return Self

> Method SampleFunction( ) Class A1
>     Self:oZContainer:ZClassMethod1( )
>     Self:oZContainer:ZClassMethod2( )

> You haven't exactly inherited from Class Z, but you've instantiated a
> Container in Class A1 which holds an instance of Class Z.  You can then
call
> methods of Class Z.  As I said however, depending on the design of Class
Z,
> this may not be possible for you.

> HTH,

> Greg

 
 
 

1. Legacy Class, implementation with class A in class B parameter...

Hello,

Hello, I have some questions about implementing CORBA with legacy class
inC++(which was not develooped for this...).

I have 2 legacy class:

//------------------
Classe LcDatabase
//------------------
 bool Open( const char* szPathname);
 bool Close();
...}

//------------------
Classe LcAdmLookup
//------------------
 long Count(const LcDatabase& Database, const char* CountryName);
...}

IDL

module Napi
 {
 interface Database
  {
  boolean Open(in string szPathname);
  void Close();
  };
 interface AdmLookup
  {
  long Count(in Database Db, in string CountryName);
  };
 };

IMPLEMENTATION

class DatabaseImpl: public POA_Napi::Database
{
protected:
    LcDatabase Db;   //Legacy class
public:
    CORBA::Boolean Open(const char * szPathname)
        {
         CORBA::Boolean res = Db.Open(szPathname);
         return res;
        };
    void Close()
        {
         Db.Close();
        };

class AdmLookupImpl: public POA_Napi::AdmLookup
{
public:
 virtual CORBA::Long Count(Napi::Database_ptr DbI)
    {
     LcAdmLookup Count( Db, "Test" );
    }

Here, the problem, is that 'Db' should be a reference of LcDatabase and not
DatabaseImpl
How can I use an get the LcDatabase instance from DatabaseImpl instance in
AdmLookupImpl..., could you give me the exemple.

Thanks for your HELP.

2. SIGNNSF.EXE

3. Class C subnet mask on class B network

4. Oracle Workgroup 2000 Performance

5. What are legacy classes, wat zijn legacy classes?

6. Dos 3.3 disk

7. Type case from base class to children class.

8. Capturing ^c flags in BASIC.

9. xbox console Class A and Class B

10. MNP Protocol Specifications - Class 4 & Class 5

11. Debugging C++ classes using library String class

12. US-OH-Cincinnati: PowerBuilder 4.0 Training Class-Advanced Class