473,509 Members | 2,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Friend variable scope not accessable through object

I have 'project1' whereas I use the classes/modules of that assembly
in 'project2'. If an item in project1 is declared as 'object', the
properties and methods on that object declared as friend are not
accessable. A simple example:
create a class library 'project1' with the following:

Public Class myPublicClass
Friend Function myFriendFunction()
End Function
End Class

Public Class myTestClass
Public TestScope As Object

Public Sub New()
TestScope = New myPublicClass
TestScope.myFriendFunction()
End Sub
End Class
Now compile/create the assembly. In another project try:
dim TestProject1 as project1.myTestClass = new project1.myTestClass

This will error as: Public member 'myFriendClass' on type
'myPublicClass' not found

Now here is the catch! In project1.myTestClass, change the
declaration type of TestScope from 'Object' to 'myPublicClass' and
execute the test case again. It works! Why doesn't the first
scenario work and the second does? And this is just a simple example,
my real-world situation dictates that the variable may be one of
several different classes so it's type would be the generic 'Object'.
Please don't offer the solution of typing the variable as the specific
class. Any help/explanation is appreciated.
Nov 18 '05 #1
0 963

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

Similar topics

27
2634
by: Dave Anderson | last post by:
Last September, some of us engaged in a discussion of freeing resources in ASP scripts written in JScript. It can be seen here: http://tinyurl.com/2flzt I recently read Eric Lippert's article on...
10
2285
by: Piotr Wyderski | last post by:
Hello, is it possible to reuse a friend operator which is defined inside a class? I'd like to obtain the following behaviour: class integer { integer operator +(signed long int v) const...
134
7749
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
1
2226
by: timbobd | last post by:
I have encountered a situation that I don't understand. When I call a sub of Friend scope (in an object with Friend scope), I am getting an error "Public member 'subname' not found in type...
5
1811
by: Steven T. Hatton | last post by:
This note appears in the discussion of name hiding and uniqueness: §3.3 #4 This note is item #6 in the discussion of "Point of declaration" §3.3.1 #6 What exactly do these statements mean?...
5
2001
by: Steven Nagy | last post by:
Hi, I ran a simple test today. I created a web app that calls a static variable which self increments. I then accessed the same app from another machine and the variable increased, indicating...
1
25621
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
3
1727
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
112
5350
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
7344
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
7412
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...
0
7505
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...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
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
4730
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
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
441
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.