Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

Visibility modifiers: public, private, ??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_iycrd - 08 Mar 2006 07:40 GMT
I have one class that is used as a low-level utility class by other
classes in the same assembly.  I'd like to make sure it's not visible
outside the assembly.

C# has modifiers 'public', 'private', and 'internal'.  Internal
relates to access within an assembly. Does C++ have anything
analogous?
Bruno van Dooren - 08 Mar 2006 07:57 GMT
>  I have one class that is used as a low-level utility class by other
> classes in the same assembly.  I'd like to make sure it's not visible
[quoted text clipped - 3 lines]
> relates to access within an assembly. Does C++ have anything
> analogous?

If you are making a managed classlib in C++/CLI, then yes. It allows the
same access control mechanisms as C#.

In native C++ there is no such thing.
You have public, private, friend and protected, but there is no difference
in method / member access between usage inside or outside a library.

Signature

Kind regards,
   Bruno.
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

David Anton - 08 Mar 2006 15:04 GMT
Both managed C++ (2003) and C++/CLI have the equivalent:

C++/CLI:
If a top-level type: use "private"
else: use "internal"

Managed C++ (2003):
use "public private"

Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

>  I have one class that is used as a low-level utility class by other
> classes in the same assembly.  I'd like to make sure it's not visible
[quoted text clipped - 3 lines]
> relates to access within an assembly. Does C++ have anything
> analogous?
_iycrd - 09 Mar 2006 07:00 GMT
>Both managed C++ (2003) and C++/CLI have the equivalent:
>
>C++/CLI:
>If a top-level type: use "private"
>else: use "internal"

The 'UtilClass' in question needs to be used by multiple classes in
the same assembly, so it must be top-level.  Looks like there is no
way to restrict UtilClass so it's not visible outside the assembly?
David Anton - 09 Mar 2006 15:00 GMT
(As I posted previously):
C++/CLI:
If a top-level type: use "private" - this will allow use from anywhere in
the assembly, but not outside of the assembly (if not top-level, use
"internal").

Managed C++ (2003):
use "public private" (the more restrictive modifier applies outside the
assembly, making it invisible outside the assembly).
Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

> >Both managed C++ (2003) and C++/CLI have the equivalent:
> >
[quoted text clipped - 5 lines]
> the same assembly, so it must be top-level.  Looks like there is no
> way to restrict UtilClass so it's not visible outside the assembly?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.