Visibility modifiers: public, private, ??

I

_iycrd

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?
 
G

Guest

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?

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.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
G

Guest

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"

--
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

_iycrd

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?
 
G

Guest

(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).
--
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top