🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages Started by Paul Anderson Tue, 04 Mar 2003 16:18
multiple inheritance and the VCL
#17735
Author: Paul Anderson
Date: Tue, 04 Mar 2003 16:18
25 lines
2165 bytes
I would like to make a base class that essentially acts as an interface to
all forms in my application.  I would like to then create forms which will
derive from the base class using the following class declaration:

class TFrom1 : public TForm, public BaseClass

Borland, however, will not let me compile this.  Can someone PLEASE, PLEASE,
PLEASE tell me why!!!  Any ideas on how I could inbed common functionality
into a form so that I can have a clean interface to them.  I need to ensure
EVERY form will implement a certain function.  I don't really care that it
is a form, only that we have a contract that the function I need will be
implemented and I can call it.

I will be storing the base class pointers in a vector<BaseClass> myForms and
calling a function something like myForms[x].UpdateState();

Please help if you can!!

The reason this is important is because I want IDE independent capabilities.
Users will derive from my base class and make their forms and I want to call
the UpdateState function and not care about whether it is a Borland TForm or
a MSVC++ form.  Does anyone know why I can't do multiple inheritance with a
Borland form?????

THANK YOU SOOOOO MUCH!!!
Re: multiple inheritance and the VCL
#17743
Author: Stephan
Date: Tue, 04 Mar 2003 17:34
44 lines
2671 bytes
Hi,
last I heard, the VCL does not allow multiple inheritance.
I don't know the reason, but I heard it's a strict adherence to the concept
of
Object Oriented Programming

The way around this, for you, is to create a class that inherits the TForm
and implements your "common" functionality.
such as:
    class TCommonForm: public TForm

Then, when you create a new form, change the inherated
from "TForm" to "TCommonForm"

Have Fun!
Stephan

"Paul Anderson" <paul.anderson@jhuapl.edu> wrote in message
news:3e64d1be@newsgroups.borland.com...
I would like to make a base class that essentially acts as an interface to
all forms in my application.  I would like to then create forms which will
derive from the base class using the following class declaration:

class TFrom1 : public TForm, public BaseClass

Borland, however, will not let me compile this.  Can someone PLEASE, PLEASE,
PLEASE tell me why!!!  Any ideas on how I could inbed common functionality
into a form so that I can have a clean interface to them.  I need to ensure
EVERY form will implement a certain function.  I don't really care that it
is a form, only that we have a contract that the function I need will be
implemented and I can call it.

I will be storing the base class pointers in a vector<BaseClass> myForms and
calling a function something like myForms[x].UpdateState();

Please help if you can!!

The reason this is important is because I want IDE independent capabilities.
Users will derive from my base class and make their forms and I want to call
the UpdateState function and not care about whether it is a Borland TForm or
a MSVC++ form.  Does anyone know why I can't do multiple inheritance with a
Borland form?????

THANK YOU SOOOOO MUCH!!!
Re: multiple inheritance and the VCL
#17748
Author: Remy Lebeau (TeamB)
Date: Tue, 04 Mar 2003 18:05
11 lines
1328 bytes
This is not an API issue.  Please don't cross-post, it is against Borland's
newsgroup guidelines (http://www.borland.com/newsgroups).  Only post to the
single most appropriate group.


Gambit

"Paul Anderson" <paul.anderson@jhuapl.edu> wrote in message
news:3e64d1be@newsgroups.borland.com...
> I would like to make a base class that essentially acts
> as an interface to all forms in my application.
Re: multiple inheritance and the VCL
#17690
Author: Alisdair Meredith
Date: Thu, 06 Mar 2003 11:24
24 lines
1903 bytes
Stephan wrote:

> The way around this, for you, is to create a class that inherits the TForm
> and implements your "common" functionality.
> such as:
>     class TCommonForm: public TForm
> 
> Then, when you create a new form, change the inherated
> from "TForm" to "TCommonForm"

Not very helpful if you want to add functionality to a group of
controls.  For instance, we wanted to add our own validation/databinding
to several standard VCL controls.  We do not control the base class, and
our implementation must then rely on knowing each possible derived class
in order to cast and handle each correctly.

Delphi gets around this using interfaces, supporting Multiple Interface
Inheritence for several years.  BCB6 finally gets limitted support for
this with pure abstract base classes, see similar thread in
.language.cpp for details.

-- 
AlisdairM
Team Thai Kingdom
Re: multiple inheritance and the VCL
#17701
Author: Stephan
Date: Thu, 06 Mar 2003 16:08
41 lines
2540 bytes
Hi!
Well, all I can say is that the solution to a problem is always
done with the tools available.

I'm a beginner at C++, and am in the process of teaching myself
how to approach a problem using the concepts of OOP. Part of this
is learning how to tackle a problem in a manner consistent with the
solution techniques available. It isn't always possible, and sometimes
it requires approaching the problem in a different manner.

As a consulting Engineer once told me,
"I want to design an anti-gravity car, and I have it mostly done.
I have the control surfaces for steering, I have the avionics for detecting
other vehicles and obstructions, and I know how to make it descend.
As soon as I solve the small problem of going up, I'll be done."

soo....
Have Fun!
Stephan

"Alisdair Meredith" <alisdair.meredith@uk.renaultf1.com> wrote in message
news:3E672FE1.C4CC3277@uk.renaultf1.com...
Stephan wrote:

> The way around this, for you, is to create a class that inherits the TForm
> and implements your "common" functionality.
> such as:
>     class TCommonForm: public TForm
>
> Then, when you create a new form, change the inherated
> from "TForm" to "TCommonForm"

Not very helpful if you want to add functionality to a group of
controls.  For instance, we wanted to add our own validation/databinding
to several standard VCL controls.  We do not control the base class, and
our implementation must then rely on knowing each possible derived class
in order to cast and handle each correctly.

--
AlisdairM
Team Thai Kingdom
Re: multiple inheritance and the VCL
#17689
Author: Alisdair Meredith
Date: Thu, 06 Mar 2003 16:33
29 lines
2476 bytes
Stephan wrote:

> I'm a beginner at C++, and am in the process of teaching myself
> how to approach a problem using the concepts of OOP. Part of this
> is learning how to tackle a problem in a manner consistent with the
> solution techniques available. It isn't always possible, and sometimes
> it requires approaching the problem in a different manner.

Well, Multiple Inheritance is a standard feature of the C++ language,
and some libraries are designed around its use (as 'mixin' classes)  If
BCB is a C++ compiler you would expect this feature.

VCL is implemented in Delphi, which rejected the idea of multiple
inheritance as something too prone to abuse.  Therefore VCL classes are
limited to single inheritence with TObject at the root.  However, it has
long been observed that sharing interfaces is a valuable feature of OO,
as exemplified in Java.  Therefore around Delphi 3/4 it gained the
ability to implement multiple interfaces so long as only one 'concrete'
class descends from TObject.  This feature has taken a long time to
migrate to C++.

We are left with a compiler for a language that supports MI, a class
library implemented in a language that supports multiple interfaces, yet
until last version we were unable to use it, and even now it is somewhat
limited.  I think it was a fair question to ask <g>

-- 
AlisdairM
Team Thai Kingdom
Re: multiple inheritance and the VCL
#17711
Author: Stephan
Date: Thu, 06 Mar 2003 19:07
45 lines
2722 bytes
Hi,
    Please don't misunderstand, it's not that I agree or disagree with
whether or not MI is good, expected, etcetera.


MI could have solved some of my programming tasks a lot more
easily than the route I had to go.

I have read arguments in several beginner books pro and con MI.
I would have to become a lot more proficient in C++ to have
the background to make an intelligent decision.

just thinking about it, it seems to me that creating a class library would
take a longer period of time if classes are limited to single inheritance,
so I would guess that decision wasn't lightly made.

but all this is getting away from the original question in this thread,
and doesn't help the guy who is using a tool that doesn't support MI ;-)

"Alisdair Meredith" <alisdair.meredith@uk.renaultf1.com> wrote in message
news:3E677863.21FAFB3@uk.renaultf1.com...
Stephan wrote:

> Part of using the concepts of OOP
> is learning how to tackle a problem in a manner consistent with the
> solution techniques available.

Multiple Inheritance is a standard feature of the C++ language,

VCL is implemented in Delphi, which rejected the idea of multiple
inheritance as something too prone to abuse.

it has long been observed that sharing interfaces is a valuable feature
of OO as exemplified in Java.

We are left with a compiler for a language that supports MI, a class
library implemented in a language that supports multiple interfaces, yet
until last version we were unable to use it, and even now it is somewhat
limited.

I think it was a fair question to ask <g>

--
AlisdairM
Team Thai Kingdom
Re: multiple inheritance and the VCL
#17629
Author: Rob
Date: Fri, 07 Mar 2003 11:23
26 lines
2037 bytes
Fail to see why this is in the api newsgroup;  would set followup
to the cpp.language or vcl newsgroups if I knew how :-)

"Stephan" <slaska@devarinc.com> wrote in message
news:3e64e3b0$1@newsgroups.borland.com...
> Hi,
> last I heard, the VCL does not allow multiple inheritance.
> I don't know the reason, but I heard it's a strict adherence to the
concept
> of
> Object Oriented Programming

OOP has nothing to do with multiple inheritence, or lack of it.

The reason the VCL only allows multiple inheritence is historic.
The VCL was originally implemented in object pascal, which
only supports single inheritence.  One of the side effects of that
is that the object layout of VCL classes in memory was
incompatible with the object layout later used by Borland
C++ compilers to implement multiple inheritence (eg layout
of virtual function tables, etc etc).

It would be technically possible for the VCL, if coded in C++,
to use multiple inheritence.  However, then the object layouts
would be incompatible with objects compiled using
Delphi (particularly the older version of Delphi).
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads