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 ? 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 ?
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 ?
"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 ?
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.
"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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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# ?
|
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...
|
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
|
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; }
}
}
| |
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 {
|
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...
|
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...
|
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
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |