0
我完全無法解決以下編譯錯誤:衝突的聲明類型/值不匹配
#include <iostream>
#include <boost/lockfree/queue.hpp>
class C
{
public:
static int size;
};
int C::size = 10;
template <class temp>
class B: public temp
{
class A
{
public:
static A pool[temp::size];
static boost::lockfree::queue<A*> mpool;
static bool firstTime;
};
public:
void show() { std::cout << "Called Show" << std::endl; }
};
template <class temp>
bool B<temp>::A::firstTime = true;
template <class temp>
typename B<temp>::A B<temp>::A::pool[temp::size];
template <class temp>
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
int main()
{
B<C> d;
d.show();
}
它指出以下錯誤 - 我想努力,但未能解決問題 - 幫助需要:
test11.cpp:37:39: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class A0, class A1, class A2> class boost::lockfree::queue'
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
^
test11.cpp:37:39: error: expected a type, got '(B<temp>::A * <expression error>)'
test11.cpp:37:58: error: invalid type in declaration before '(' token
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
^
test11.cpp:37:58: error: conflicting declaration 'int B<temp>::A::mpool'
test11.cpp:21:40: note: previous declaration as 'boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool'
static boost::lockfree::queue<A*> mpool;
^
test11.cpp:37:58: error: declaration of 'boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool' outside of class is not definition [-fpermissive]
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
我添加了typename並嘗試了,但是在編譯過程中我仍然得到相同的錯誤 – Prakash
您能否編輯您的問題以包含'typename'關鍵字,並顯示出現的錯誤。我的猜測是你把它放在了錯誤的地方。 –
謝謝 - :: A *>固定它,但我完全不明白如何? –
Prakash