actually problem is in class A it is not getting declaration of class B
becoz there u tried to tell one member of class when declaring friend.If
with forwrard declaration when specifying data member of class require its
defination.
class A;
class B//:public A
{
public:
int func(A ob);
};
class A
{
int a;
public:
int f2(){}
friend int B::func(A ob);
};
int B::func(A ob)
{
}
use above it will work fine . but if u uncomment the public A it will give
error becoz it want actual declaration not only forwrd declartion.
One more thing why are using friend in above case its not good thing use *
protected* the data member which u want to make accessibly in
dervied class instead of friend its not good sign.
On Sun, Jul 31, 2011 at 9:25 PM, Anika Jain <[email protected]> wrote:
> class B;
>
> class A
> {
> int a;
> public:
> int f2(){}
> friend int B::func(A ob);
> };
>
> class B:public A
> {
> public:
> int func(A ob)
> {
> }
> };
>
>
> why compilation error is coming over here for friend statement n forward
> protype declaration of class B ??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
Pandharinath Gorde
+91-9620557641
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.