|
-
April 13th, 2003, 08:57 AM
#1
Question about friend function.
Hi, everyone!
I have often noticed that someone declares a friend
fucntion inside a class (in the .h file of the class)
and give the definition of the function in the .cpp file
of the same class. I want to know whether this
method is correct? Does it have some weak points? Where should
correct place which we give the definition (Note: not the declaration)
of the function?
Another question is, if I define the function like below, what is the
scope of the function? (i.e. where can compiler find the function?)
Here is the sample codes I noticed:
in A.h
--------
class A {
friend int functionA();
void memberfunction();
}
--------
A.cpp
--------
A::memberfunction()
{
//implemention
}
int functionA()
{
//implemention
}
--------
Thanks in advance,
George
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
|