I've been attempting a lot of template meta programming lately, particularly using CRTP, and have come across the titular error. Specifically error C2352 'MeshComponent::InternalSetEntity': illegal call of non-static member function.
A Minimal, Complete, and Verifiable snippit of my code is as such:
Component.h
class Entity //Forward declaration
template<class T, EventType... events>
class Component {
private:
short entityID;
public:
void SetEntity(Entity& _entity) { entityID = _entity.GetId(); T::InternalSetEntity(_entity); }
protected:
void InternalSetEntity(Entity& _entity) {}
};
MeshComponent.h
#include "Component.h"
class MeshComponent : public Component<MeshComponent> {
friend class Component<MeshComponent>;
protected:
void InternalSetEntity(Entity& _entity);
};
MeshComponent.cpp
#include "MeshComponent.h"
void MeshComponent::InternalSetEntity(Entity& _entity) {
//Nothing yet
}
Entity.h
class Entity {
private:
short id;
public:
short GetId() {return id;}
};
I am not declaring any static functions, nor do I want to. In fact I require these to be member functions as they will operate on instance specific data.
If someone knows why this error is occurring and a possible solution to the problem I would greatly appreciate it. Thanks in advance.