473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

class-based access control VS instance-based access control

xz
Why C++ (as well as Java) adopts class-based access control instead of
instance-based access control?

I had never paid attention to whether an access-control is class-based
or instance-based but only intuitively thought that the latter was the
one being used.

Since it does not seem to make sense to let an instance "a1" of Class
"A" to have access to the private data of instance "a2" of the same
Class A, does it?
Jan 7 '08 #1
8 2112
xz wrote:
Why C++ (as well as Java) adopts class-based access control instead of
instance-based access control?
Mostly because of the different purpose of those. Class-based has the
purpose to prevent coding mistakes, whereas instance-based looks like
a security measure. C++ wasn't designed with security in mind.
I had never paid attention to whether an access-control is class-based
or instance-based but only intuitively thought that the latter was the
one being used.

Since it does not seem to make sense to let an instance "a1" of Class
"A" to have access to the private data of instance "a2" of the same
Class A, does it?
That's an incomplete statement. Since it doesn't, then what? What
conclusion do you expect to derive from "since it doesn't make sense"?
And think of the fact that it doesn't make sense to you, but obviously
makes a lot of sense to millions of other C++ programmers who never
complain about that feature. What does it say?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #2
xz
On Jan 7, 2:29 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
xz wrote:
Why C++ (as well as Java) adopts class-based access control instead of
instance-based access control?
Thanks for you reply.
Mostly because of the different purpose of those. Class-based has the
purpose to prevent coding mistakes, whereas instance-based looks like
a security measure. C++ wasn't designed with security in mind.
I thought the access control was designed in the purpose for
security......
And it is obviously a danger to let "a1" (of class A) to have access
to the private data of "a2".
If you wanna control the privileges of accesses from the outside
world, it's straightforward that any access from outside should be
controlled, whether it is from an instance of different class or the
same class.
Well, but you said class-based is not for security......
I had never paid attention to whether an access-control is class-based
or instance-based but only intuitively thought that the latter was the
one being used.
Since it does not seem to make sense to let an instance "a1" of Class
"A" to have access to the private data of instance "a2" of the same
Class A, does it?

That's an incomplete statement. Since it doesn't, then what? What
conclusion do you expect to derive from "since it doesn't make sense"?
And think of the fact that it doesn't make sense to you, but obviously
makes a lot of sense to millions of other C++ programmers who never
complain about that feature. What does it say?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #3
xz
On Jan 7, 2:29 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
xz wrote:
Why C++ (as well as Java) adopts class-based access control instead of
instance-based access control?

Mostly because of the different purpose of those. Class-based has the
purpose to prevent coding mistakes, whereas instance-based looks like
a security measure. C++ wasn't designed with security in mind.
Then how about Java?
>
I had never paid attention to whether an access-control is class-based
or instance-based but only intuitively thought that the latter was the
one being used.
Since it does not seem to make sense to let an instance "a1" of Class
"A" to have access to the private data of instance "a2" of the same
Class A, does it?

That's an incomplete statement. Since it doesn't, then what? What
conclusion do you expect to derive from "since it doesn't make sense"?
And think of the fact that it doesn't make sense to you, but obviously
makes a lot of sense to millions of other C++ programmers who never
complain about that feature. What does it say?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #4
xz wrote:
On Jan 7, 2:29 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>xz wrote:
>>Why C++ (as well as Java) adopts class-based access control instead
of instance-based access control?

Mostly because of the different purpose of those. Class-based has
the purpose to prevent coding mistakes, whereas instance-based looks
like a security measure. C++ wasn't designed with security in mind.
Then how about Java?
No, thanks.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #5
xz
On Jan 7, 3:10 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
xz wrote:
On Jan 7, 2:29 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
xz wrote:
Why C++ (as well as Java) adopts class-based access control instead
of instance-based access control?
Mostly because of the different purpose of those. Class-based has
the purpose to prevent coding mistakes, whereas instance-based looks
like a security measure. C++ wasn't designed with security in mind.
Then how about Java?
No, thanks.
So you are a fan of tea? :)

OK, let's ask it seriously.
I think Java (the programming language provided by Sun, which is a
company instead of the shining sun in the sky) was designed "with
security in mind", then why Java's access control is also class-based
instead of instance-based?
>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #6
xz wrote:
On Jan 7, 3:10 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>xz wrote:
>>On Jan 7, 2:29 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
xz wrote:
Why C++ (as well as Java) adopts class-based access control
instead of instance-based access control?
>>>Mostly because of the different purpose of those. Class-based has
the purpose to prevent coding mistakes, whereas instance-based
looks like a security measure. C++ wasn't designed with security
in mind. Then how about Java?
>No, thanks.
So you are a fan of tea? :)

OK, let's ask it seriously.
I think Java (the programming language provided by Sun, which is a
company instead of the shining sun in the sky) was designed "with
security in mind", then why Java's access control is also class-based
instead of instance-based?
Why are you asking about Java in a C++ newsgroup? The only answer
to your question here is "who cares?"

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 7 '08 #7
xz wrote:
>
And it is obviously a danger to let "a1" (of class A)
to have access to the private data of "a2".
Try to write a copy ctor and assignment operator for your class A.

Probably, access to the private data of object of the same class can
be disabled by default, and a kind of static_cast<will exist to
explicitly change type of reference to enabled.

But what the errors and where have you met already with the access is
enabled by default?

Maksim A. Polyanin
old page about some C++ improvements:
http://grizlyk1.narod.ru/cpp_new
Jan 8 '08 #8
On Jan 7, 8:58 pm, xz <zhang.xi...@gmail.comwrote:
Why C++ (as well as Java) adopts class-based access control instead of
instance-based access control?
Because you couldn't implement copy construction otherwise. If
a language supports value semantics for user defined types, it
pretty much has to use class based access control.
I had never paid attention to whether an access-control is
class-based or instance-based but only intuitively thought
that the latter was the one being used.
Since it does not seem to make sense to let an instance "a1"
of Class "A" to have access to the private data of instance
"a2" of the same Class A, does it?
And how do you implement a copy constructor otherwise?

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jan 8 '08 #9

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

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and...
9
by: mead | last post by:
What kind of classes is qualified as "concrete classes"? When should a member function in a class defined as "pure virtual" and when as "virtual"? Thanks!
0
by: Leslaw Bieniasz | last post by:
Cracow, 16.09.2004 Hi, I have a problem with compiling the following construction involving cross-calls of class template methods, with additional inheritance. I want to have three class...
2
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert"...
4
by: Nataraj M | last post by:
Hi, I just don't want anybody derive a class from my class. For example: /////////////////////// //MY CODE class MyClass { .... }; ///////////////////////
16
by: pawel.pabich | last post by:
Hajo, I would like to have 2 my own partial classes. For example: Default.aspx.cs Default2.aspx.cs and they both will relate to Default.aspx page.
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
5
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base...
9
by: silversurfer2025 | last post by:
Hello everyone, I am currently having problems with a C++ abstract class. I have a class FrameWork.h which defines some methods (of which some are abstract, i.e. virtual void method() = 0). In...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
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,...
0
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...
0
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...
1
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...
0
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...
0
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,...
0
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...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.