S
suresh.amritapuri
Hi,
What is wrong in this simple friend function code?
#include <iostream>
using namespace std;
class B;
class A{
public:
A():aa(10){}
void dispA(){cout << aa << endl;}
private:
int aa;
friend class B;
};
class B{
public:
B():bb(20){}
void dispB(){cout << bb + aa << endl;}
private:
int bb;
};
int main(){
A a;
B b;
b.dispB();
}
compiler (g++) says: testFriend.cpp:17: error: ‘aa’ was not declared
in this scope.
any suggestions?
thanks
suresh
What is wrong in this simple friend function code?
#include <iostream>
using namespace std;
class B;
class A{
public:
A():aa(10){}
void dispA(){cout << aa << endl;}
private:
int aa;
friend class B;
};
class B{
public:
B():bb(20){}
void dispB(){cout << bb + aa << endl;}
private:
int bb;
};
int main(){
A a;
B b;
b.dispB();
}
compiler (g++) says: testFriend.cpp:17: error: ‘aa’ was not declared
in this scope.
any suggestions?
thanks
suresh