473,769 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not inheriting members from the base

If I recall correctly, in C++ there was an access specifier that could
label a data member of a class as "can be accessed by everyone else
EXCEPT the derived class" -- an accurate opposite of "protected" . I
think I allude to the "friend" modifier in C++, which is different from
the C# "friend".

Does C# have any such specifier? Is there a method for a child class to
"not" inherit some properties off its base class?

May 16 '06 #1
4 1618
>which is different from the C# "friend".

I meant to say, _different from the C# "internal". _

May 16 '06 #2
I rekon that "sealed" modifier is that you a looking for
http://msdn2.microsoft.com/en-us/library/88c54tsw.aspx

but it prohibit this class being inherited

"Water Cooler v2" wrote:
If I recall correctly, in C++ there was an access specifier that could
label a data member of a class as "can be accessed by everyone else
EXCEPT the derived class" -- an accurate opposite of "protected" . I
think I allude to the "friend" modifier in C++, which is different from
the C# "friend".

Does C# have any such specifier? Is there a method for a child class to
"not" inherit some properties off its base class?


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 16 '06 #3
as far as I understood your question you have following:
a base class with members ( some of them can be overriden some not )
a child class that can inherint base class and override some
members(properi es/methods)

there is no such keyword in C# but you can implement this in C# as
declare member that cannot be overriden as non-virtual methods -the
ones that can be overriden will be virtual

in case you have some method in base class and you want completely
different functionality/parameters you can delcare it using new keyword
Hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 16 '06 #4
Michael Nemtsev wrote:
I rekon that "sealed" modifier is that you a looking for
http://msdn2.microsoft.com/en-us/library/88c54tsw.aspx

but it prohibit this class being inherited
The original poster is asking about access, not inheritance.
To my knowledge, there is no such modifier in C#. Nor was it
in C++.
"Water Cooler v2" wrote:
If I recall correctly, in C++ there was an access specifier that could
label a data member of a class as "can be accessed by everyone else
EXCEPT the derived class" -- an accurate opposite of "protected" . I
think I allude to the "friend" modifier in C++, which is different from
the C# "friend".

Does C# have any such specifier? Is there a method for a child class to
"not" inherit some properties off its base class?

May 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6887
by: Andy Jarrell | last post by:
I'm trying to inherit from a specific class that has an overloaded operator. The problem I'm getting is that certain overloaded operators don't seem to come with the inheritance. For example: // TestA.h --------------------------------------- #include <iostream> enum Aval { FIRST_VALUE,
0
1059
by: source | last post by:
I have a base class called Automobile, and a child class called CAR When I create an object of CAR, it should have all the base class members/fields But when I see the CAR object in quick watch I see bunch of empty lines in my view. Is there anything wrong, why don't I see my base class variables/fields. All of the base class variables and fields are public. Any clue. source
15
1713
by: JustSomeGuy | last post by:
this doesn't want to compile.... class image : public std::list<element> { element getElement(key k) const { image::iterator iter; for (iter=begin(); iter != end(); ++iter) { element &elem(*iter);
11
2168
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain methods, such as public void Add(MyClass c). How can I enforce the same behavior (of requiring to implement a member with a new return type in an inherited class) in the master class (similar to the CollectionBase)? I have a class called...
4
1199
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this so I'd like to create all controls form now on from this base control. So, for example, I inherit from this base control and add the further controls required to form this part of my UI. Call this ClassB
4
1365
by: Xero | last post by:
Hello. I am using vb.net. There are two forms in my project. One is 'base' and the other one is 'savecurrent'. There is a value stored in a textbox called 'qc_a' in 'base'. I want to inherit it in 'savecurrent' when a button (located in 'savecurrent') is clicked. So a declared an Object varible, whose name is 'equation' in 'savecurrent' and typed in the following code:
2
1406
by: TJO | last post by:
I am having difficulty understanding why I cannot access my base .ascx class members from my inherited class. I create a base .ascx control and add a method. public partial class myWebControlBase : System.Web.UI.UserControl { public virtual void _foo(){ } }
5
1354
by: dragoncoder | last post by:
I got this code from a friend of mine. #include <iostream> using namespace std; class Base { int i; public:
4
1699
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 : public virtual base
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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
10208
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...
1
9987
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
8867
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...
1
7404
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
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
3
2812
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.