1st, simple question, is there a protected in C#?
I mean a comparable keyword like the C++ protected, which defines a member
as accessable for decendants, but not for the outside world.
Then, a more complicated question, is privat in C#, then comparable with
protected, or private in C++. Or to say it in other words, if I declare a
member private in C#, can I access it in a decendant class? 7 6379
My4thPersonality wrote: 1st, simple question, is there a protected in C#?
I mean a comparable keyword like the C++ protected, which defines a member as accessable for decendants, but not for the outside world.
Then, a more complicated question, is privat in C#, then comparable with protected, or private in C++. Or to say it in other words, if I declare a member private in C#, can I access it in a decendant class?
The protected and private in C# have the same meaning as in C++. C#
extends access modifiers by adding internal and protected internal,
which are equal to public and protected with respect to the module they
appear in and private to the outer world.
My4thPersonality wrote: 1st, simple question, is there a protected in C#?
I mean a comparable keyword like the C++ protected, which defines a member as accessable for decendants, but not for the outside world.
Then, a more complicated question, is privat in C#, then comparable with protected, or private in C++. Or to say it in other words, if I declare a member private in C#, can I access it in a decendant class?
The protected and private in C# have the same meaning as in C++. C#
extends access modifiers by adding internal and protected internal,
which are equal to public in the module in which they appear and private
or protected respectively to the outer world.
Stefan Simek <si**********@triaxis.nospam.sk> wrote: Then, a more complicated question, is privat in C#, then comparable with protected, or private in C++. Or to say it in other words, if I declare a member private in C#, can I access it in a decendant class?
The protected and private in C# have the same meaning as in C++.
Is that strictly true? I *thought* that in C++, you couldn't access the
private members of one instance from another instance (whereas you can
in C#). This is only based on what others have said, however - I
haven't checked the spec.
There's also the concept of private inheritance in C++, but not in C#.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] wrote: Stefan Simek <si**********@triaxis.nospam.sk> wrote:
Then, a more complicated question, is privat in C#, then comparable with protected, or private in C++. Or to say it in other words, if I declare a member private in C#, can I access it in a decendant class?
The protected and private in C# have the same meaning as in C++.
Is that strictly true? I *thought* that in C++, you couldn't access the private members of one instance from another instance (whereas you can in C#). This is only based on what others have said, however - I haven't checked the spec.
Yes, you can access the private fields from another instance in C++. There's also the concept of private inheritance in C++, but not in C#.
HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Andreas Mueller <me@privacy.net> wrote: Is that strictly true? I *thought* that in C++, you couldn't access the private members of one instance from another instance (whereas you can in C#). This is only based on what others have said, however - I haven't checked the spec.
Yes, you can access the private fields from another instance in C++.
My mistake. It must be another language I'm thinking of... I wonder
which?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Andreas Mueller <me@privacy.net> wrote: > Is that strictly true? I *thought* that in C++, you couldn't access the > private members of one instance from another instance (whereas you can > in C#). This is only based on what others have said, however - I > haven't checked the spec.
Yes, you can access the private fields from another instance in C++.
My mistake. It must be another language I'm thinking of... I wonder which?
None I know of. In fact, "How come instance 1 can access private members of
instance 2?" seems to be a common newbie question about C#, C++, and Java
alike.
Actually, C++/CLI has "internal" and also has an equivalent to C#'s protected
internal: "public protected".
--
David Anton www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
"Stefan Simek" wrote: My4thPersonality wrote: 1st, simple question, is there a protected in C#?
I mean a comparable keyword like the C++ protected, which defines a member as accessable for decendants, but not for the outside world.
Then, a more complicated question, is privat in C#, then comparable with protected, or private in C++. Or to say it in other words, if I declare a member private in C#, can I access it in a decendant class?
The protected and private in C# have the same meaning as in C++. C# extends access modifiers by adding internal and protected internal, which are equal to public in the module in which they appear and private or protected respectively to the outer world. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christian Meier |
last post by:
Hi dear programmers
I looked for the difference between private and protected inheritance, but
couldn't find anything.
Here is my sample code:
#include <iostream>
using std::cout;
using...
|
by: seesaw |
last post by:
Compared to "public",
how does "private/protected" in inheritance change relationship between
classes
what is the purpose to define constructor as "private/protected"?
is there any usage to...
|
by: Act |
last post by:
Why is it suggested to not define data members as "protected"?
Thanks for help!
|
by: Adam H. Peterson |
last post by:
I just made an observation and I wondered if it's generally known (or
if I'm missing something). My observation is that static protected
members are essentially useless, only a hint to the user. ...
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you...
|
by: newbie120 |
last post by:
Hi all
maybe its just been a long day, but i have a question about call access
modifiers in C#. Consider the following code.
namespace Application
{
private class Class1
{
int i;
|
by: Fir5tSight |
last post by:
Hi All,
I have a small C#.NET program that is as follows:
using System;
class A
{
protected int x = 123;
}
|
by: Morten71 |
last post by:
Just curious.
In VB, if I, from design-mode in vs2005, double-click a button (or any
other control), the code-behind file opens and the default declaration
is automatically inserted with method...
|
by: Mayur H Chauhan |
last post by:
All,
For my knowledge, if I declare Class as follow, then it thows
compilation error.
Protected Class Book
End Class
Even same for...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |