خرید بک لینک

Vote count: 0

I have two classes A and B defined in A.h, A.cpp and B.h, B.cpp respectively. Class A has a structure that I want to use in a function of Class B. Because Class B is included in Class A, I can't include class A in Class B as it will lead to circular dependency. Code for all the files are given below: A.h

#include B.h
namespace common {
    class A {
    public:
        static struct strctOfA {
           float p1 = 2;
        } structA;
    }
}

A.cpp

#include A.h
using namespace common;
class A {
    B b;
    b.functionOfB(structA);
}

B.h

namespace common {
    class B {
    public:
         functionOfB(??);
    }
}

B.cpp

#include A.h
using namespace common;
class B {
    functionOfB(??) {
        // Want to use structA here;        
    }
}

I looked into StackOverflow and found a thread quite close to my problem, however, they it either doesn't explains the answer or I am not able to understand their solution. Please help me with this.

Thanks

asked 22 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 خرداد 1395 ساعت: 0:25

صفحه بندی