I'm attempting to create a generic method that in C# would do the following:
Код: Выделить всё
public class Component{}
public class GameObject{
public T AddComponent() where T : Component{}
}
Код: Выделить всё
template
Comp* AddComponent()
{
return new Component(); // Work in progress
}
Код: Выделить всё
CompSubType & comp = AddComponent();
Источник: https://stackoverflow.com/questions/781 ... -parameter