Re: litb is teh famous (private access specifier is private no more)

Discussion in 'C++' started by jacob navia, Mar 31, 2012.

  1. jacob navia

    jacob navia Guest

    Le 30/03/12 19:53, Leigh Johnston a écrit :
    [SNIP]

    If you want really private structures just use C:

    struct foo;
    typedef struct foo *pFoo;

    Now you can use struct foo and pFoo everywhere without knowing anything
    about it. You can't allocate a foo, just a pointer to it, and you can't
    have a local variable of that type. It is 100% hidden and since you
    haven't got any description of its internal fields there is NO WAY you
    can access them.

    This is much stronger than C++ "private". It has some drawbacks too, the
    main one is that you can't do some hack to actually use the protected
    fields :)

    jacob
     
    jacob navia, Mar 31, 2012
    #1
    1. Advertising

  2. jacob navia

    gwowen Guest

    On Mar 31, 9:47 am, jacob navia <> wrote:
    > Le 30/03/12 19:53, Leigh Johnston a écrit :


    > If you want really private structures just use C:
    >
    > struct foo;
    > typedef struct foo *pFoo;


    You can (of course) do this forward declaration technique in C++
    too...

    And indeed, if you want to keep the implementation secret, its the
    only way to go (although, lets be honest, a sufficiently determined
    attacker who can inspect the object files will probably be able to
    subvert that too - *security is hard*).
     
    gwowen, Apr 3, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eduard W. Lohmann
    Replies:
    1
    Views:
    650
  2. Raterus
    Replies:
    0
    Views:
    457
    Raterus
    Jun 2, 2004
  3. mit
    Replies:
    0
    Views:
    436
  4. Jerry Camel
    Replies:
    5
    Views:
    607
    Jerry Camel
    Sep 27, 2005
  5. dost
    Replies:
    5
    Views:
    1,188
    Phlip
    Apr 28, 2006
Loading...

Share This Page