473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Visibility modifiers: public, private, ??

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?

Mar 8 '06 #1
4 1815
> 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.
br**********************@hotmail.com
Remove only "_nos_pam"

Mar 8 '06 #2
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

"_iycrd" wrote:
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?

Mar 8 '06 #3
On Wed, 8 Mar 2006 07:04:30 -0800, David Anton
<Da********@discussions.microsoft.com> wrote:
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?

Mar 9 '06 #4
(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

"_iycrd" wrote:
On Wed, 8 Mar 2006 07:04:30 -0800, David Anton
<Da********@discussions.microsoft.com> wrote:
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?

Mar 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kchalla | last post by:
Can anybody let me know the difference between public and private class access modifiers? Thanks in advance
2
by: Abdessamad Belangour | last post by:
Hi, I want to get the visiblity kind of a FieldInfo object. The "IsPublic" ans "IsPrivate" properties give the required information for public and private visibilities. My questions are: 1. What...
7
by: Chris Adams | last post by:
Hello, I just finished an online tutorial regarding Visual Inheritance. It was very informative, despite the fact that I am still unclear on two of the settings for the Modifiers property. ...
4
by: Colin Desmond | last post by:
Is it possible to write an attribute that changes the visibility of a class (public/private) etc based on some pre-compiler define symbol? We're writing some classes which will be called by an...
3
by: RitualDave | last post by:
This compiles and runs successfully in VS2005: ref class A { private: ~A() { this->!A(); } // private! !A() { } // private! }; ....
11
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
2
by: Jamey Bon | last post by:
I am a C# newbie. I am having a tough time with several issues of scope and visibility. In short, why can't I see any of the elements of Form1 (the base form generated by the "Windows...
2
by: devgupta01 | last post by:
I have seen the class with public and without modifiers and method with public, protected or private modifiers. I am confused how to decide modifiers for a class?
6
by: BOMEz | last post by:
So i've recently been starting to program PHP in an object oriented way, but I'm running into some difficulties in from a design stand point and from an object oriented stand point: Issue 1: In my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.