You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
so when I eventually looked at the rust and java code... I realized there is no virtual and override (well it does show in java, but not explicit)
so why not add C# as another examples of polymorphism in appendix B
// C# implementation of the Taylor series example program based on// subtyping given in Appendix B of the proposal "Improved run-time// polymorphism for Fortran".//usingSystem;publicinterfaceIDeriv{voidDeriv1();}publicinterfaceIHDeriv:IDeriv{voidDeriv2();}publicabstractclassDerivativeBase:IDeriv{publicvirtualvoidDeriv1(){Console.WriteLine(" Default derivative implementation.");}}publicclassDerivF:DerivativeBase{publicoverridevoidDeriv1(){Console.WriteLine(" 1st derivative of function F!");}}publicclassHDerivF:DerivativeBase,IHDeriv{publicoverridevoidDeriv1(){Console.WriteLine(" 1st derivative of function F!");}publicvoidDeriv2(){Console.WriteLine(" 2nd derivative of function F!");}}publicclassDerivG:DerivativeBase{publicoverridevoidDeriv1(){Console.WriteLine(" 1st derivative of function G!");}}publicclassHDerivG:DerivativeBase,IHDeriv{publicoverridevoidDeriv1(){Console.WriteLine(" 1st derivative of function G!");}publicvoidDeriv2(){Console.WriteLine(" 2nd derivative of function G!");}}publicclassTaylor{privatereadonlyIDeriv_calc;publicTaylor(IDerivcalc){_calc=calc;}publicvoidTerm1(){_calc.Deriv1();}publicvoidEvaluate(){Console.WriteLine("Evaluating Taylor series using");Term1();}}publicclassHTaylor{privatereadonlyIHDeriv_calc;publicHTaylor(IHDerivcalc){_calc=calc;}publicvoidTerm1(){_calc.Deriv1();}publicvoidTerm2(){_calc.Deriv2();}publicvoidEvaluate(){Console.WriteLine("Evaluating Taylor series using");Term1();Term2();}}classProgram{staticvoidMain(){IDerivderivg=newDerivG();IDerivderivf=newDerivF();IHDerivhderivg=newHDerivG();IHDerivhderivf=newHDerivF();TaylorevalG=newTaylor(derivg);TaylorevalF=newTaylor(derivf);HTaylorhevalG=newHTaylor(hderivg);HTaylorhevalF=newHTaylor(hderivf);evalG.Evaluate();Console.WriteLine();evalF.Evaluate();Console.WriteLine();hevalG.Evaluate();Console.WriteLine();hevalF.Evaluate();}}
The text was updated successfully, but these errors were encountered:
Phyllee
changed the title
Add C# as another example.
Add C# as another examples
Dec 11, 2024
Hi!
so when I eventually looked at the rust and java code... I realized there is no virtual and override (well it does show in java, but not explicit)
so why not add C# as another examples of polymorphism in appendix B
The text was updated successfully, but these errors were encountered: