472,122 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

MC++ changing access in a derived class

Since a C++ using declaration isn't allowed in MC++, is there a way to
specify that a property, method, event, or field's access can be changed in
a derived class, ie. is protected in one class and is made public in a
derived class ?
Nov 17 '05 #1
6 1613
I do not believe this feature is supported in .NET.
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Since a C++ using declaration isn't allowed in MC++, is there a way to
specify that a property, method, event, or field's access can be changed in a derived class, ie. is protected in one class and is made public in a
derived class ?

Nov 17 '05 #2
Daniel O'Connell wrote:
I do not believe this feature is supported in .NET.
I don't think so either.

A neat feature in C++ Builder was the ability to design a base class
component with full functionality, called something like
"CustomAComponentName", many of whose properties, methods, and events were
protected, and then each derived class with only refined functionality,
called something like "AComponentName", could decide which of these areas
could be made public ( or __published ) in the derived class. As it is now,
if a base class exposes a property, method, or event, there is no way to
eliminate that exposure in a derived class. Yet this last is often a valid
programming paradigm. My derived class is often a more particular version of
the base class which exposes a simpler interface. But in .NET the full base
class interface most always be exposed. That seems a deficiency of the
language design.
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Since a C++ using declaration isn't allowed in MC++, is there a way
to specify that a property, method, event, or field's access can be
changed in a derived class, ie. is protected in one class and is
made public in a derived class ?

Nov 17 '05 #3

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Daniel O'Connell wrote:
I do not believe this feature is supported in .NET.
I don't think so either.

A neat feature in C++ Builder was the ability to design a base class
component with full functionality, called something like
"CustomAComponentName", many of whose properties, methods, and events were
protected, and then each derived class with only refined functionality,
called something like "AComponentName", could decide which of these areas
could be made public ( or __published ) in the derived class. As it is

now, if a base class exposes a property, method, or event, there is no way to
eliminate that exposure in a derived class. Yet this last is often a valid
programming paradigm. My derived class is often a more particular version of the base class which exposes a simpler interface. But in .NET the full base class interface most always be exposed. That seems a deficiency of the
language design.

The oft quoted Liskov substitution principle[1] probably fits here. In any
given case, a given class should be able to be used as its parent, meaning
that you shouldn't be able to reduce privledge to a given member, or should
only be able to do so in appearence(like explicit interface implementation
or VB's renamable interface methods(not sure of hte name for that)). I can
however see the purpose in allowing it to be expanded, if proper care is
taken. It is currently a CLR issue, however it is one that could atleast be
taken into consideration. If you wish to provide simplier interfaces, you
may want to consider an approach based on the concept of an interface
instead of modifying classes. Interfaces are bound to scale across other
languages better than modifying protections, and do end with a cleaner
system. There may be attributes that will allow you to hide members from the
intellisense list as well, but I don't know off hand.

1. http://en2.wikipedia.org/wiki/Liskov...tion_principle
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Since a C++ using declaration isn't allowed in MC++, is there a way
to specify that a property, method, event, or field's access can be
changed in a derived class, ie. is protected in one class and is
made public in a derived class ?


Nov 17 '05 #4
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Daniel O'Connell wrote:
I do not believe this feature is supported in .NET.
I don't think so either.

A neat feature in C++ Builder was the ability to design a base class
component with full functionality, called something like
"CustomAComponentName", many of whose properties, methods, and
events were protected, and then each derived class with only
refined functionality, called something like "AComponentName", could
decide which of these areas could be made public ( or __published )
in the derived class. As it is now, if a base class exposes a
property, method, or event, there is no way to eliminate that
exposure in a derived class. Yet this last is often a valid
programming paradigm. My derived class is often a more particular
version of the base class which exposes a simpler interface. But in
.NET the full base class interface most always be exposed. That
seems a deficiency of the language design.

The oft quoted Liskov substitution principle[1] probably fits here.
In any given case, a given class should be able to be used as its
parent, meaning that you shouldn't be able to reduce privledge to a
given member, or should only be able to do so in appearence(like
explicit interface implementation or VB's renamable interface
methods(not sure of hte name for that)). I can however see the
purpose in allowing it to be expanded, if proper care is taken.


Actually I think one should be able to reduce functionality in a derived
class in order to simplify a class's access. Certainly, of course, one
should be able to expand functionality, as this is the basic idea of OOP
programming.
It is
currently a CLR issue, however it is one that could atleast be taken
into consideration. If you wish to provide simplier interfaces, you
may want to consider an approach based on the concept of an interface
instead of modifying classes. Interfaces are bound to scale across
other languages better than modifying protections, and do end with a
cleaner system. There may be attributes that will allow you to hide
members from the intellisense list as well, but I don't know off
hand.


I understand interfaces, the equivalent in C++ of abstract classes. I will
consider them more in my own design.
Nov 17 '05 #5

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:eZ**************@TK2MSFTNGP10.phx.gbl...
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Daniel O'Connell wrote:
I do not believe this feature is supported in .NET.

I don't think so either.

A neat feature in C++ Builder was the ability to design a base class
component with full functionality, called something like
"CustomAComponentName", many of whose properties, methods, and
events were protected, and then each derived class with only
refined functionality, called something like "AComponentName", could
decide which of these areas could be made public ( or __published )
in the derived class. As it is now, if a base class exposes a
property, method, or event, there is no way to eliminate that
exposure in a derived class. Yet this last is often a valid
programming paradigm. My derived class is often a more particular
version of the base class which exposes a simpler interface. But in
.NET the full base class interface most always be exposed. That
seems a deficiency of the language design.

The oft quoted Liskov substitution principle[1] probably fits here.
In any given case, a given class should be able to be used as its
parent, meaning that you shouldn't be able to reduce privledge to a
given member, or should only be able to do so in appearence(like
explicit interface implementation or VB's renamable interface
methods(not sure of hte name for that)). I can however see the
purpose in allowing it to be expanded, if proper care is taken.


Actually I think one should be able to reduce functionality in a derived
class in order to simplify a class's access. Certainly, of course, one
should be able to expand functionality, as this is the basic idea of OOP
programming.

It leaves a balacne, if you reduce functionality, you loose the OOP concept
of being able to use a derived class as a base. In nearly all cases, I would
consider loosing that to be breaking OOP. If you want to produce a new
interface, I say create a new class and call into the class you wish to base
off of.
It is
currently a CLR issue, however it is one that could atleast be taken
into consideration. If you wish to provide simplier interfaces, you
may want to consider an approach based on the concept of an interface
instead of modifying classes. Interfaces are bound to scale across
other languages better than modifying protections, and do end with a
cleaner system. There may be attributes that will allow you to hide
members from the intellisense list as well, but I don't know off
hand.


I understand interfaces, the equivalent in C++ of abstract classes. I will
consider them more in my own design.

Nov 17 '05 #6
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:eZ**************@TK2MSFTNGP10.phx.gbl...
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Daniel O'Connell wrote:
> I do not believe this feature is supported in .NET.

I don't think so either.

A neat feature in C++ Builder was the ability to design a base
class component with full functionality, called something like
"CustomAComponentName", many of whose properties, methods, and
events were protected, and then each derived class with only
refined functionality, called something like "AComponentName",
could decide which of these areas could be made public ( or
__published ) in the derived class. As it is now, if a base class
exposes a property, method, or event, there is no way to eliminate
that exposure in a derived class. Yet this last is often a valid
programming paradigm. My derived class is often a more particular
version of the base class which exposes a simpler interface. But in
.NET the full base class interface most always be exposed. That
seems a deficiency of the language design.

The oft quoted Liskov substitution principle[1] probably fits here.
In any given case, a given class should be able to be used as its
parent, meaning that you shouldn't be able to reduce privledge to a
given member, or should only be able to do so in appearence(like
explicit interface implementation or VB's renamable interface
methods(not sure of hte name for that)). I can however see the
purpose in allowing it to be expanded, if proper care is taken.


Actually I think one should be able to reduce functionality in a
derived class in order to simplify a class's access. Certainly, of
course, one should be able to expand functionality, as this is the
basic idea of OOP programming.

It leaves a balacne, if you reduce functionality, you loose the OOP
concept of being able to use a derived class as a base. In nearly all
cases, I would consider loosing that to be breaking OOP. If you want
to produce a new interface, I say create a new class and call into
the class you wish to base off of.


I agree with you. One shouldn't reduce functionality but one can simplify
what is already there by adding a simpler set of functionality for a derived
class. You have made the correct point that removing functionality destroys
polymorphic access through a base class pointer ( or reference ). Definitely
my error in not considering that.
Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Edward Diener | last post: by
1 post views Thread by Arnaud Debaene | last post: by
3 posts views Thread by Daniel Lidström | last post: by
13 posts views Thread by dragoncoder | last post: by
8 posts views Thread by WebSnozz | last post: by
15 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.