I am not sure about what you want to achieve. I tried to figure it out considering this other question, but it could help to have more details of what features/behavior your parent, child, and Parent p = new Child() should do.
I've put together a quick overview of a couple common ways for dealing with inheritance. But you might be looking for a more specific case.
package Inheritance
import SI = Modelica.SIunits;
connector PositivePin "Positive pin of an electrical component"
SI.ElectricPotential v "Potential at the pin";
flow SI.Current i "Current flowing into the pin";
end PositivePin;
partial model OnePort
"Component with two electrical pins p and n and current i from p to n"
SI.Voltage v "Voltage drop of the two pins (= p.v - n.v)";
SI.Current i "Current flowing from pin p to pin n";
Inheritance.PositivePin p "Positive electrical pin";
Modelica.Electrical.Analog.Interfaces.NegativePin n "Negative electrical pin";
equation
v = p.v - n.v;
0 = p.i + n.i;
i = p.i;
end OnePort;
model Resistor "Ideal linear electrical resistor"
parameter SI.Resistance R = 1
"Resistance at temperature T_ref";
extends Inheritance.OnePort;
equation
v = R*i;
end Resistor;
model Circuit
Resistor r( R=10);
Modelica.Electrical.Analog.Basic.Ground ground;
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=1);
equation
connect(constantVoltage.n, ground.p);
connect(constantVoltage.p, r.n);
connect(r.p, ground.p);
end Circuit;
end Inheritance;
So that the instance p of the connector class PositivePin
Inheritance.PositivePin p;
brings the variables i, v in the partial model OnePort (see language spec for potential and flow variables).
In the model class Resistor
extends Inheritance.OnePort;
instantiates the variables
- i, v
- p.i, p.v throught the instance p of the class PositivePin
- n.i, n.v through the instance n of the class NegativePin
as well as the equations
- v = p.v - n.v;
- 0 = p.i + n.i;
- i = p.i;
Finally, in the model class Circuit
Resistor r(R=10);
instantiates the Resistor class with a so-called modifier, so that the instance r has resistance value R=10 instead of the default class value R=1