|
-
Sep 14th, 2000, 08:54 AM
#1
Thread Starter
Member
I created a property procedure in a class module.
The Get procedure is public.
The Let procedure is friend.
I compiled the project into a DLL and then added a reference to the new DLL to a brand new project.
I can still access the friend procedure from code in my new project.
Because of this I am a little confused as to how or what the friend declare does.
I thought, for instance, if I created a series of classes and compiled it into a DLL that the friend keyword would allow the different classes in the DLL to communicate the properties to one another without exposing those properties to a project that the compiled DLL was added to. Sorta like handing private messages back in forth in class without the teacher (the new project the DLL was added to) being able to see the notes. =)
-
Sep 14th, 2000, 08:58 AM
#2
transcendental analytic
Well, i have use of Friend keyword when i pass or return global types from a class, otherways i get an error, but i'm not sure if this is just something in vb5.
I think Friend keyword lets properties, functions and subs to be used as if they were public
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 14th, 2000, 09:09 AM
#3
Gregg your definition of the Friend keyword is correct.
If you have declared the Get proceduce as public but the Let procedure as Friend an other project would be able to read the property value but not set a new value to it.
-
Sep 14th, 2000, 09:30 AM
#4
Thread Starter
Member
What I cannot figure out....
Okay, so if I compiled the class (with a property that is declared friend) as a DLL then any project I add that to can use that friended property BECAUSE the dll is part of the project and friended properties can be read anywhere in the project they are a part of.
If I compiled the project as an EXE then another project trying to uses the friended property in that EXE would NOT be able to see it.
Is that correct?
Thanks in advance for your help.
-
Sep 14th, 2000, 09:34 AM
#5
Thread Starter
Member
CreateObject vs. GetObject
Correct me if I am wrong:
The only major I see between these two:
The CreateObject function allows one to create the object TO a certian location. (create the object, put it there)
The GetObject function allows one to create an object FROM a certian location. (go there, find the object, create it)
Don't need details, just wondering if that is a good summary.
thanks in advance
-
Sep 14th, 2000, 09:36 AM
#6
If you declare Public property Get and a Friend property Let in your class then it means when you compile your DLL it will be read only property, because property Let won't be exposed to the user. But you can use this property in your code accross your whole application.
-
Sep 14th, 2000, 09:40 AM
#7
Re: CreateObject vs. GetObject
Originally posted by Gregg
Correct me if I am wrong:
The only major I see between these two:
The CreateObject function allows one to create the object TO a certian location. (create the object, put it there)
The GetObject function allows one to create an object FROM a certian location. (go there, find the object, create it)
Don't need details, just wondering if that is a good summary.
thanks in advance
Yupp, I would say that that is a correct description.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|