Does Modelica have something equivalent to C++ templates? I would like to build a class that would process an input of type T, but T would be known only when instantiating the class. I tried to pass the type as a parameter but it gives errors.
1
votes
1 Answers
3
votes
You can use replaceable types/classes.
model M
replaceable class C; // = some partial class if you need an interface constrainedby ...
C c;
end M;
model Test
M m1(redeclare class C = C1);
M m2(redeclare class C = C2);
end Test;
See more in the Modelica Specification 4.5 Class declarations https://modelica.org/documents/ModelicaSpec32Revision2.pdf.