Witam.
Stworzyłem klasę mającą działać jak właściwości w C# itp:
KLASA WŁAŚCIWOŚCI
template<typename P_TYPE>
class vClassProperty
{
public:
typedef P_TYPE(__thiscall * GetterType)();
typedef void (__thiscall * SetterType)(const P_TYPE&);
private:
GetterType __getter;
SetterType __setter;
public:
vClassProperty(GetterType getter, SetterType setter) :
__getter(getter),
__setter(setter)
{
}
vClassProperty & operator=(const P_TYPE & val)
{
__setter(val);
return *this;
}
operator P_TYPE()
{
return __getter();
}
};
Chciałem użyć jej potem w innej klasie:
class IWindow : public IGeneric
{
protected:
vEvent *m_event = nullptr;
// Getters and setters:
virtual void __setFullscreen(const bool &_value) = 0;
virtual bool __isFullscreen(void) = 0;
virtual void __setWidth(const int& value) = 0;
virtual int __getWidth(void) = 0;
virtual void __setHeight(const int& value) = 0;
virtual int __getHeight(void) = 0;
//--------------------------------------------------
public:
typedef IGeneric Super;
__forceinline void AttachEvent(vEvent *_ev)
{
m_event = _ev;
}
virtual void Create(const char* title, int width, int height) = 0;
virtual void CreateContext() = 0;
virtual void Destroy() = 0;
virtual void PollEvent() = 0;
virtual void Swap() = 0;
vClassProperty<bool> Fullscreen;
vClassProperty<int> Width, Height;
IWindow() :
Fullscreen(__isFullscreen, __setFullscreen),
Width(__getWidth, __setWidth),
Height(__getHeight, __setHeight)
{
}
};
Ale w trakcie kompilacji mam następujące błędy:
no matching function for call to 'vClassProperty<bool>::vClassProperty(<unresolved overloaded function type>, <unresolved overloaded function type>)'
no matching function for call to 'vClassProperty<int>::vClassProperty(<unresolved overloaded function type>, <unresolved overloaded function type>)'
Ma ktoś pomysł, jak to naprawić?
Korzystam z najnowszego TDM-GCC-64.
Projekt przenoszę z Visual Studio 2013, gdzie używałem to tego celu __declspec(property).