Re: [Dev-C++] A member access question
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Siva C. <siv...@ya...> - 2006-09-24 12:18:33
|
I should have used a set function rather than a get
function as a private member of class Bin in my
earliar mail! A get function through an inner class
makes no sense I guess.
--- Siva Chandra <siv...@ya...> wrote:
> 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
>
>
-------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get
> the chance to share your
> opinions on IT & business topics through brief
> surveys -- and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE:
> http://www23.brinkster.com/noicys/devcpp/ub.htm
>
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|