P
Paul
In the code below I have the operator << work OK for classes A and B
but cannot make it work for class C. The error I am getting currently
points to this line:
friend std:stream& operator <<(std:stream&, const B::C&);
saying class C (in const B::C&) is inaccessible, although, as I see
it, this has been added to class B:
friend std:stream& operator <<(std:stream&, const C&);
Is there a way to make it work?
Thank you.
#include <ostream>
class A {
class B {
class C {
friend std:stream& operator <<(std:stream&, const C&);
};
friend std:stream& operator <<(std:stream&, const B&);
friend std:stream& operator <<(std:stream&, const C&);
};
friend std:stream& operator <<(std:stream&, const A&);
friend std:stream& operator <<(std:stream&, const B&);
friend std:stream& operator <<(std:stream&, const B::C&);
};
inline std:stream& operator <<(std:stream& os, const
A&) { return os; }
inline std:stream& operator <<(std:stream& os, const
A::B&) { return os; }
inline std:stream& operator <<(std:stream& os, const
A::B::C&) { return os; }
but cannot make it work for class C. The error I am getting currently
points to this line:
friend std:stream& operator <<(std:stream&, const B::C&);
saying class C (in const B::C&) is inaccessible, although, as I see
it, this has been added to class B:
friend std:stream& operator <<(std:stream&, const C&);
Is there a way to make it work?
Thank you.
#include <ostream>
class A {
class B {
class C {
friend std:stream& operator <<(std:stream&, const C&);
};
friend std:stream& operator <<(std:stream&, const B&);
friend std:stream& operator <<(std:stream&, const C&);
};
friend std:stream& operator <<(std:stream&, const A&);
friend std:stream& operator <<(std:stream&, const B&);
friend std:stream& operator <<(std:stream&, const B::C&);
};
inline std:stream& operator <<(std:stream& os, const
A&) { return os; }
inline std:stream& operator <<(std:stream& os, const
A::B&) { return os; }
inline std:stream& operator <<(std:stream& os, const
A::B::C&) { return os; }