<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Templates]]></title><description><![CDATA[<p>Hallo ich habe bitte eine Frage:</p>
<p>Ich habe ein KlassenTemplate Graph&lt;int n&gt;. In der Main möchte ich jetzt dieses Template mit mit einen Wert belegen denn ich zur Laufzeit im Programm abfrage.[cpp]<br />
int main(void)<br />
{<br />
unsigned int menu = 911;<br />
//int n;</p>
<p>cout &lt;&lt; &quot;Implementierung eines Spanning Tree \n \n&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;Anzahl der Ecken des Graphen : &quot;; cin &gt;&gt; n;<br />
cout &lt;&lt; &quot;\n&quot; &lt;&lt; endl;</p>
<p>while(menu != 0)<br />
{<br />
<strong>Graph&lt;n&gt; graph;</strong><br />
if (menu == 911)<br />
{<br />
cout &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (1) : insertEdge |&quot; &lt;&lt; &quot;| (5) : spanningTree |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (2) : adjacent |&quot; &lt;&lt; &quot;| (6) : displayTree |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (3) : displayEdges |&quot; &lt;&lt; &quot;| (7) : Startwerte |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (4) : printbinary matrix |&quot; &lt;&lt; &quot;| (0) : Programm Beenden |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot; &gt;&gt; Hinweis - 911 holt dieses Menue zurueck / 999 Bildschirm loeschen &lt;&lt; \n&quot; &lt;&lt; endl;<br />
}<br />
if (menu == 999)<br />
system( &quot;cls&quot; );</p>
<p>do<br />
{<br />
cin.sync(); cin.clear();<br />
cout &lt;&lt; &quot;Eingabe &gt; &quot;;<br />
cin &gt;&gt; menu;<br />
}<br />
while((menu &gt; 7 || menu &lt; 0) &amp;&amp; menu != 911 &amp;&amp; menu != 999);<br />
cout &lt;&lt; endl;</p>
<p>unsigned int i;<br />
unsigned int j;<br />
unsigned int root;</p>
<p>switch(menu)<br />
{<br />
case 1:<br />
cin.sync(); cin.clear();<br />
cout &lt;&lt; &quot;Einfuegen einer Kante: \n&quot;;<br />
cout &lt;&lt; &quot;Eingabe (i) : &quot;; cin &gt;&gt; i; cout &lt;&lt; &quot;Eingabe (j) : &quot;; cin &gt;&gt; j;<br />
cout &lt;&lt; &quot;\n&quot; &lt;&lt; endl;<br />
try<br />
{<br />
graph.insertEdge(i,j);<br />
}<br />
catch (<strong>Graph::BadVertex &amp;bv</strong>)<br />
{<br />
cout &lt;&lt; &quot;|| BadVertex Exception || \nEs gibt diese Ecke nicht im Graph:\n&quot;;<br />
cout &lt;&lt; &quot;(i) : &quot; &lt;&lt; bv.getI() &lt;&lt; &quot;\n&quot;;<br />
cout &lt;&lt; &quot;(j) : &quot; &lt;&lt; bv.getJ() &lt;&lt; &quot;\n\n&quot;;<br />
}[cpp]<br />
Wieso funktioniert das nicht. Bei den dickmarkierten Punkten gibt es die Problemfälle.<br />
Danke<br />
Pejtr</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150473/templates</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 16:10:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150473.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Jun 2006 21:17:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Templates on Fri, 16 Jun 2006 21:17:20 GMT]]></title><description><![CDATA[<p>Hallo ich habe bitte eine Frage:</p>
<p>Ich habe ein KlassenTemplate Graph&lt;int n&gt;. In der Main möchte ich jetzt dieses Template mit mit einen Wert belegen denn ich zur Laufzeit im Programm abfrage.[cpp]<br />
int main(void)<br />
{<br />
unsigned int menu = 911;<br />
//int n;</p>
<p>cout &lt;&lt; &quot;Implementierung eines Spanning Tree \n \n&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;Anzahl der Ecken des Graphen : &quot;; cin &gt;&gt; n;<br />
cout &lt;&lt; &quot;\n&quot; &lt;&lt; endl;</p>
<p>while(menu != 0)<br />
{<br />
<strong>Graph&lt;n&gt; graph;</strong><br />
if (menu == 911)<br />
{<br />
cout &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (1) : insertEdge |&quot; &lt;&lt; &quot;| (5) : spanningTree |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (2) : adjacent |&quot; &lt;&lt; &quot;| (6) : displayTree |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (3) : displayEdges |&quot; &lt;&lt; &quot;| (7) : Startwerte |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;| (4) : printbinary matrix |&quot; &lt;&lt; &quot;| (0) : Programm Beenden |&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; &quot; ----------------------------------&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot; &gt;&gt; Hinweis - 911 holt dieses Menue zurueck / 999 Bildschirm loeschen &lt;&lt; \n&quot; &lt;&lt; endl;<br />
}<br />
if (menu == 999)<br />
system( &quot;cls&quot; );</p>
<p>do<br />
{<br />
cin.sync(); cin.clear();<br />
cout &lt;&lt; &quot;Eingabe &gt; &quot;;<br />
cin &gt;&gt; menu;<br />
}<br />
while((menu &gt; 7 || menu &lt; 0) &amp;&amp; menu != 911 &amp;&amp; menu != 999);<br />
cout &lt;&lt; endl;</p>
<p>unsigned int i;<br />
unsigned int j;<br />
unsigned int root;</p>
<p>switch(menu)<br />
{<br />
case 1:<br />
cin.sync(); cin.clear();<br />
cout &lt;&lt; &quot;Einfuegen einer Kante: \n&quot;;<br />
cout &lt;&lt; &quot;Eingabe (i) : &quot;; cin &gt;&gt; i; cout &lt;&lt; &quot;Eingabe (j) : &quot;; cin &gt;&gt; j;<br />
cout &lt;&lt; &quot;\n&quot; &lt;&lt; endl;<br />
try<br />
{<br />
graph.insertEdge(i,j);<br />
}<br />
catch (<strong>Graph::BadVertex &amp;bv</strong>)<br />
{<br />
cout &lt;&lt; &quot;|| BadVertex Exception || \nEs gibt diese Ecke nicht im Graph:\n&quot;;<br />
cout &lt;&lt; &quot;(i) : &quot; &lt;&lt; bv.getI() &lt;&lt; &quot;\n&quot;;<br />
cout &lt;&lt; &quot;(j) : &quot; &lt;&lt; bv.getJ() &lt;&lt; &quot;\n\n&quot;;<br />
}[cpp]<br />
Wieso funktioniert das nicht. Bei den dickmarkierten Punkten gibt es die Problemfälle.<br />
Danke<br />
Pejtr</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1079184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1079184</guid><dc:creator><![CDATA[Pejtr]]></dc:creator><pubDate>Fri, 16 Jun 2006 21:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to Templates on Fri, 16 Jun 2006 21:43:59 GMT]]></title><description><![CDATA[<p>a) Verwende [cpp]-Tags<br />
b) Templateargumente müssen immer zur Compilezeit feststehen.<br />
c) Meine Kristallkugel ist kaputt und ich hab von Graph&lt;&gt; deshalb keinen Schimmer</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1079194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1079194</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Fri, 16 Jun 2006 21:43:59 GMT</pubDate></item></channel></rss>