CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Threaded View

  1. #1
    Join Date
    Apr 2009
    Location
    Netherlands
    Posts
    91

    Using friend classes can improve encapsulation

    My theory is that using friend classes can improve encapsulation when you use them together with factory and/or manager classes.

    Say I have a class that is to unable to contstruct or initialize itself or I have a factory pattern where it is decided at runtime what object to create. My theory is by making the class that needs to be constructed befriend the manager/factory class will allow you to hide alot of class variables that shouldn't be directly accessed, while still allowing the manager/factory to initilize them.

    This is my view on the subject but I would appreciate some input from other developpers.
    Last edited by AlastrionaAdair; May 4th, 2009 at 05:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured