<?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[Template Übergabe von char*]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich brauch mal Hilfe bei einem Template. Ich möchte eine Funktion, die mir den Inhalt eines string o.ä. in eine Zahl konvertiert.<br />
atof usw. macht mir immer ein Kommafehler, der nicht sein soll.</p>
<p>Das Template:</p>
<pre><code class="language-cpp">template&lt;class t&gt;
    t StringToNumb(const char* sstr) {
        stringstream Str;
        t number;
        Str &lt;&lt; sstr;
        Str &gt;&gt; number;
        return number;
    };
</code></pre>
<p>Der Aufruf:</p>
<pre><code class="language-cpp">string stmp;
//...

 StringToNumb(stmp.data());
</code></pre>
<p>Als Meldung kommt &quot;No matching function for call to 'StringToNumb(const char*)'</p>
<p>Ich hab jetzt schon diverse andere Datentypen ausprobiert, klappt aber alles nicht. Wie ist das richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/277184/template-übergabe-von-char</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 01:43:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/277184.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Nov 2010 14:06:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template Übergabe von char* on Sun, 14 Nov 2010 14:06:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich brauch mal Hilfe bei einem Template. Ich möchte eine Funktion, die mir den Inhalt eines string o.ä. in eine Zahl konvertiert.<br />
atof usw. macht mir immer ein Kommafehler, der nicht sein soll.</p>
<p>Das Template:</p>
<pre><code class="language-cpp">template&lt;class t&gt;
    t StringToNumb(const char* sstr) {
        stringstream Str;
        t number;
        Str &lt;&lt; sstr;
        Str &gt;&gt; number;
        return number;
    };
</code></pre>
<p>Der Aufruf:</p>
<pre><code class="language-cpp">string stmp;
//...

 StringToNumb(stmp.data());
</code></pre>
<p>Als Meldung kommt &quot;No matching function for call to 'StringToNumb(const char*)'</p>
<p>Ich hab jetzt schon diverse andere Datentypen ausprobiert, klappt aber alles nicht. Wie ist das richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980309</guid><dc:creator><![CDATA[Napoleon]]></dc:creator><pubDate>Sun, 14 Nov 2010 14:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to Template Übergabe von char* on Sun, 14 Nov 2010 14:28:52 GMT]]></title><description><![CDATA[<p>Hi, probier mal</p>
<pre><code class="language-cpp">int i = StringToNumb&lt;int&gt;(stmp.data());
  float f = StringToNumb&lt;float&gt;(stmp.data());
</code></pre>
<p>Hatte ich auch schon mal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ... das muss der template parameter explizit angegeben werden.</p>
<p>lg, xor</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980311</guid><dc:creator><![CDATA[xor]]></dc:creator><pubDate>Sun, 14 Nov 2010 14:28:52 GMT</pubDate></item><item><title><![CDATA[Reply to Template Übergabe von char* on Sun, 14 Nov 2010 15:35:22 GMT]]></title><description><![CDATA[<p>abgesehen davon, dass man bei std::string in der Regel nicht .data() verwendet,<br />
um an den internen char* zu kommen, sonder .c_str()...</p>
<p>davon abgesehen hat mein vorredner recht:<br />
wo sich aus den normalen Parametern der Template Parameter nicht herleiten lässt (weil er z.B. nur für den Rückgabewert verwendet wird), muss man ihn explicit angeben.</p>
<p>also immer StringToNumb&lt;ZielTyp&gt;(blabla) -&gt; Zieltyp muss angegeben werden!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980341</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sun, 14 Nov 2010 15:35:22 GMT</pubDate></item></channel></rss>