473,714 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1700
I do not believe this feature is supported in .NET.
"Edward Diener" <ed******@tropi csoft.com> wrote in message
news:ep******** ******@tk2msftn gp13.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
"CustomACompone ntName", 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******@tropi csoft.com> wrote in message
news:ep******** ******@tk2msftn gp13.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******@tropi csoft.com> wrote in message
news:%2******** *********@tk2ms ftngp13.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
"CustomACompone ntName", 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******@tropi csoft.com> wrote in message
news:ep******** ******@tk2msftn gp13.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******@tropi csoft.com> wrote in message
news:%2******** *********@tk2ms ftngp13.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
"CustomACompone ntName", 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******@tropi csoft.com> wrote in message
news:eZ******** ******@TK2MSFTN GP10.phx.gbl...
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropi csoft.com> wrote in message
news:%2******** *********@tk2ms ftngp13.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
"CustomACompone ntName", 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******@tropi csoft.com> wrote in message
news:eZ******** ******@TK2MSFTN GP10.phx.gbl...
Daniel O'Connell wrote:
"Edward Diener" <ed******@tropi csoft.com> wrote in message
news:%2******** *********@tk2ms ftngp13.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
"CustomACompone ntName", 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4341
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an inherited base member's access level in the derived class: its access level in the base class and the type of inheritance (public, protected, or private). After this determination is made, the following possibilities exist for manually changing the...
14
24598
by: Edward Diener | last post by:
In C++ one can change the access level in a derived class by the "using" keyword. So, for instance, a public method in a base class can be made private in a derived class. Is there any way of doing this in C# ?
2
2514
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a pointer or reference to a derived type of the base class's return type. In .NET the overridden virtual function is similar, but an actual parameter of the function can be a derived reference from the base class's reference also. This dichotomy...
1
1461
by: Arnaud Debaene | last post by:
Hello, I think I found a bug in VC 7.1 concerning destruction of stack objects when linking a static, non managed, C++ library within a managed C++ application. Here is a repro case : 1) Build a static, unmanaged, library containing the following 2 files. Compiles with /MDd. // FILE BaseHolder.h #pragma once
3
2235
by: Daniel Lidström | last post by:
I have a CS class I wish to write in MC++: public class UnitsCollection : ArrayList { new public Units this { get { return (Units) base; } set { base = value; } } }
13
2841
by: dragoncoder | last post by:
Consider the following code #include <iostream> class Base { public: virtual void say() { std::cout << "Base" << std::endl; } }; class Derived: public base {
2
1482
by: mrclash | last post by:
Hello, I have a class that uses some variables to access a sql database, and I want to make a derived class that inherits all the methods of this class, because the derived one will do exactly the same process that the parent one, but with a postgres database, thus I've got to use diferent type variables to acces the database. There's one big function in the class that does all the DB stuff, and I want to know if there's any way to...
8
2202
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the existing code. The options I've considered so far: 1. Create a new MC++ GUI project and add the *.c files to them and mark them with pragma unamanged. However, the /clr option does not compile *.c files, so I rename them to *.cpp, and now they...
15
3084
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I met with a strange issue that derived class function can not access base class's protected member. Do you know why? Here is the error message and code. error C2248: 'base::~base' : cannot access protected member declared in
0
8713
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9187
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9034
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.