friend member function in C++ - forward declaration not working -
I get a situation that is described.
However in my case, class B needs to know class A as it is using it, so the solution given in that thread is not working for me. I also have a forwarding function for the function. Tried to give it, but it was not working properly. It seems that each class requires the full definition of another ...
Is there any easy way to solve it? I prefer a solution that does not include new classes, which wrap one of the older classes.
Code example:
// A.h class B; // zero help not b: FB (); // Class A {Public: Friend Zero B: FB (); Zero FA () {}; Protected: zero fA_ protected () {}; }; //B.h # included "AH" class B {Private: AA; Public: Zero FB () {a.fA_protected ();} // Secure function for this function zero FB2 () (a.fA);}} (The way This is my first question, I hope that I clearly explain myself)
if You can change B to take an indicator on A, then following help can be found: (I use raw pointer because you can not use smart pointer as per the comment S): A: Public: Friend Zero B: FB (); Zero FA () {}; Preserve: zero fA_ protected () { };}; // B. H. Class A; // Further declaration class B {Private: A * A; Public: B (); ~ B (); // Rule 3B (Const B & B); // Rule 3b & operator = (3) Rule FB (); // This function should call secure function zero FB2 ();}; //B.cpp #include "Bh" #include "ah" B :: B:: A (new A) {} B :: ~ B (delete); // Rule 3b :: B Nst B & B) A (new A * (BA)) {} // Rule 3b & A. B :: Operator = (Const B & amp;) {* a = * b.a; Return * This; } // rule 3 of zero B: FB () {A-> Fa-protected ();} zero b :: fb2 () {a-> fa (); }
Comments
Post a Comment