<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Dear LEMON Users,</div><div>I want to write a class, which does e.g. some calculations on given graphs (ListDigraph, FullDigraph or own derived LEMON-graphes). Now I have to write implementations for each graph type, which could be avoided via templates.</div><div>Unfortunatly I am not very experienced with templates. How does a template access functions of the graph or even the NodeMaps, if a template doesn't know the type beforehand?</div><div><br></div><div>I added a simple sample code to show my problem.</div><div><br></div><div>I hope this is not a too complicated issue.</div><div><br></div><div>Thank you very much</div><div><br></div><div>Peter</div><div><br></div><div><br></div><div><br></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">template</span> < <span style="color: #bb2ca2">typename</span> DGR> <span style="color: #bb2ca2">class</span> outputClass {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><div style="margin: 0px; color: rgb(187, 44, 162); ">public<span style="color: #000000">:</span></div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> DGR &mGraph;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> DGR::NodeMap<<span style="color: #bb2ca2">int</span>> mMap;</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> outputClass( <span style="color: #bb2ca2">const</span> DGR &graph)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> : <span style="color: #4f8187">mGraph</span>(graph), mMap(graph){};</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">void</span> output(){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">for</span> (DGR::NodeIt n( <span style="color: #4f8187">mGraph</span> ); n!=<span style="color: #703daa">INVALID</span>; ++n) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> std::cout << <span style="color: #d12f1b">"value: "</span> << mMap[ n ] << endl;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">};</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">int</span> main( <span style="color: #bb2ca2">void</span> ){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #703daa">ListDigraph</span> g;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #4f8187">outputClass</span><<span style="color: #703daa">ListDigraph</span>> out( g );</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> out.output();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">}</div></div></body></html>