template<class Rawr>
class TestContains;
template <class T>
class TestStore//: public TestContains
{
public:
TestStore(T first, T second, T W, T H)
{
x = first;
y = second;
Width = W;
Height = H;
TestContains<T> a(x, y, Width, Height);
*b = a;
}
~TestStore() {};
T x;
T y;
T Width;
T Height;
TestContains<T>* GetRect();
protected:
private:
TestContains<T> *b;
};
共产党
template<class T>
TestContains<T>* TestStore<T>::GetRect()
{
return &b;
}
测试包含
template<class Rawr>
class TestContains
{
public:
TestContains(Rawr first, Rawr second, Rawr W, Rawr H)
{
x = first;
y = second;
Width = W;
Height = H;
}
~TestContains(){};
template <class T>
bool Contains(T Mx, T My)
{
if (Mx >= x && Mx <= x + Width && My >= y && My <= My + Height)
return true;
return false;
}
Rawr x;
Rawr y;
Rawr Width;
Rawr Height;
///friend?
template<class T>
friend class TestStore;
protected:
private:
};
执行
TestStore<int> test(0, 0, 100, 100);
if (test.GetRect().Contains(mouseX, mouseY))
{
std::cout << "Within 0, 0, 100, 100" << std::endl;
}
无论如何......所以我无法编译这个
/home/chivos/Desktop/yay/ShoeState.cpp||在成员函数'virtual void ShoeState::GameLoop(GameEngine*)':| /home/chivos/Desktop/yay/ShoeState.cpp|51|错误:在'test.TestStore::GetRect with T = int'中请求成员'Contains',它是非类类型'TestContains*'| ||=== 构建完成:1 个错误,0 个警告 ===|
我已经搞砸了很长时间,它开始困扰我!大声笑,有谁知道我做错了什么?