473,569 Members | 2,870 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 1690
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
4326
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...
14
24556
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
2502
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...
1
1452
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
2226
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
2826
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
1477
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...
8
2191
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...
15
3065
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
7605
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...
0
7917
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. ...
0
8118
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...
0
6277
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...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
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...

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.