Re: private member access
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Wed, 25 Jan 2006 11:04:44 +1100
"Peter Carlson" <peter@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OqP8rHUIGHA.3100@xxxxxxxxxxxxxxxxxxxx
> I know this is a very simple c++ question, but I thought that private
> data members were only accessible inside the class. So why is A.x
> accessible to the function IsA?
>
> class A {
> public:
> bool IsA(A &a) {
> return (a.x == x) ? true : false;
> }
> private:
> int x;
> };
>
>
> Peter
Because access rights are class-wide, not object-wide. Thus if you have
A a1, a2;
then a1 has access rights to a2 and vice versa.
--
John Carson
.
- References:
- private member access
- From: Peter Carlson
- private member access
- Prev by Date: private member access
- Next by Date: Re: UI Thread : Where's the processing?
- Previous by thread: private member access
- Next by thread: Re: private member access
- Index(es):
Relevant Pages
|