template
Comp& AddComponent()
{
return new Component(); // Work in progress
}
But I don't see how I could call that without passing a parameter. I'm thinking I could use typeof(Comp) where Comp can be any type inheriting Comp. But would there be a way closer to c# where the call ends up something like:
I'm attempting to create a generic method that in C# would do the following: [code]public class Component{}
public class GameObject{ public T AddComponent() where T : Component{} } [/code] And I'm trying to convert that to C++ and so far came up with: [code]template Comp& AddComponent() { return new Component(); // Work in progress } [/code] But I don't see how I could call that without passing a parameter. I'm thinking I could use typeof(Comp) where Comp can be any type inheriting Comp. But would there be a way closer to c# where the call ends up something like: [code]CompSubType & comp = AddComponent(); [/code]
Я хочу зарегистрировать несколько DbContext в своем приложении, чтобы сделать его более модульным. Однако многие необходимые вызовы не дублируются, например
builder.Services.AddDbContext((_, options) =>
{
// some configuration
},...
Я хочу зарегистрировать несколько DbContext в своем приложении, чтобы сделать его более модульным. Однако многие необходимые вызовы теперь дублируются, например
builder.Services.AddDbContext((_, options) =>
{
// some configuration
},...