473,503 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Friend' vs. 'Protected Friend'

Friend variables "are accessible from within the program that contains their
declaration and from anywhere else in the same assembly." according to the
VS.Net help. This sounds like a pretty broad scope!

So why, when attempting to inherit a form from a base form class, is
'Friend' inadequate to give inherited forms 'public'-style access to
inherited controls? I.E. - i have a base form with two group boxes on it.
When they are declared 'Friend', i can't drag and drop controls into them in
inherited forms in the visual form designer. When they are declared
'Protected Friend', they work as expected.

Getting back to the definition of Friend - isn't any inherited form within
the same project going to be considered "...within the program... [or] ...in
the same assembly."? By now, my empirical evidence indicates that this not
the case, but i am wondering WHY?!

TIA! =)
Nov 20 '05 #1
2 13004
Sometimes declaring something as Friend is illegal as it exposes a public
object.

Example:

Friend Enum Foo
Alpha
Beta
Gamma
End Enum

Public Class Bar
Public Sub Baz(ByVal Moo As Foo)
'
End Sub
End Class

Baz has Moo declared as Foo for it's parameter. Foo is a friend type, and
Bar is a public class. It is invalid because A public type cannot expose a
friend type.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
: Friend variables "are accessible from within the program that contains
their
: declaration and from anywhere else in the same assembly." according to the
: VS.Net help. This sounds like a pretty broad scope!
:
: So why, when attempting to inherit a form from a base form class, is
: 'Friend' inadequate to give inherited forms 'public'-style access to
: inherited controls? I.E. - i have a base form with two group boxes on it.
: When they are declared 'Friend', i can't drag and drop controls into them
in
: inherited forms in the visual form designer. When they are declared
: 'Protected Friend', they work as expected.
:
: Getting back to the definition of Friend - isn't any inherited form within
: the same project going to be considered "...within the program... [or]
....in
: the same assembly."? By now, my empirical evidence indicates that this
not
: the case, but i am wondering WHY?!
:
: TIA! =)
:
:
Nov 20 '05 #2
If the class that derives from DataEntryForm is in the same assembly (same
exe or same dll) as DataEntryForm, any friend member on DataEntryForm
should be accessible by it - can you show us the code that tries to access,
and what is the error it gives?

Nov 20 '05 #3

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

Similar topics

15
6556
by: Samee Zahur | last post by:
Question: How do friend functions and static member functions differ in terms of functionality? I mean, neither necessarily needs an object of the class to be created before they are called and...
8
2515
by: Carlos J. Quintero | last post by:
Hi, As you know the current keywords "protected internal" (C#) or "Protected Friend" (VB.Net) means "Protected Or internal" (C#) or "Protected Or Friend" (VB.Net), that is, the member is...
7
13977
by: Steve | last post by:
I'm just curious, why did give VB.Net a Friend keyword but not C#?
7
9799
by: Jesper | last post by:
I need to grant a class access to protected fields of another class in the way its possible in C++ with the friend keyword. However I would like to keep the class protected towards other class...
5
9861
by: | last post by:
hello there, what is the difference between Shared and Protected Shared? where can I read more about theses kind of variables (or whatever they are....sorry, don't know the word in eng.) ...
2
1546
by: Vark | last post by:
Interesting behavior I came across today where a child form has full access to a base form class' controls, but you can only modify the controls' properties in code, not in the visual designer....
8
1464
by: toton | last post by:
Hi, I have a parser interface , which is class IParser{ public: void readHeader(Document& doc)= 0; void readCC(CC& cc) = 0; }; Now, there are 3 kinds of parser which extends (implements)...
3
1725
by: Neal | last post by:
Hi all Why do I get a compiler error with the following code. Friend Class SomeClass End Class Public Class SomePublicClass Protected Friend Function AMethod As SomeClass
12
2794
by: MiG | last post by:
Hello, Consider the following code snippet: class B { protected: B() {} ~B() {} };
3
1716
by: tonvandenheuvel | last post by:
Hi all, the following code does not compile in gcc 4.0.2: 3 class Outer 4 { 5 class B; 6 7 template<typename T>
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
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
7330
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...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.