|
From: Siva C. <siv...@ya...> - 2006-09-24 12:12:51
|
Hello all,
I have this problem with member access of a C++ class.
Let A and B be two classes. I want A to have access to
only few specific private members of B. I have been
implementing it using an inner class of class B as
below.
class A
{
...
};
class B
{
public:
class Bin
{
friend class A;
private:
int get_private_int_a_of_B(const B &b)
{
return b.a;
}
}
private:
int a;
... other private members;
};
The class Bin need not have to be an inner class - it
can be an external friend of class B. However, making
it an inner class makes the code neater, and makes B a
bit more encapsulated I feel. So, my question is: Is
there a better/neater way of providing access to
specific private members of a class to another
particular class?
Thanks in advance,
Siva Chandra
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|