<?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[[C++] Dynamischer-Datentyp?]]></title><description><![CDATA[<p>Ich bastle mir grad ein Virtuellen Taschenrechner, nun bin ich mit meinem Latein am ende und weiß nicht wie es weiter gehen soll. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Folgendes Problem:</p>
<p>Ich möchte einen Datentyp haben der &quot;automatisch&quot; denn Typ ermittelt wie z.B ob es sich um ein char Datentyp bzw. float Datentyp handelt und dementsprechend konvertiert in dem fall mit cast...</p>
<p>Ich habe mir schon ein FilterSytem ausgedacht:</p>
<p>Pseudo-Filtersystem:</p>
<pre><code class="language-cpp">cin&gt;&gt; whatever;

if(whatever != TYPECHAR) // Wenn whatever ein char-type ist... 
{
	// whatever in ein float-type umwandeln (mit cast)
}
esle
{
	// whatever in ein char-type umwandeln (mit cast)
}
</code></pre>
<p>Fragen:</p>
<ol>
<li>
<p>Wenn ich anstelle des PseudoAusdrucks TYPECHAR, char setze beklagt sich der Compiler. Warum?</p>
</li>
<li>
<p>Existiert überhaupt so ein &quot;dynamischer&quot; Datentyp?<br />
Habe schon vergeblich gegoogelt...</p>
</li>
<li>
<p>Falls nicht wie kann ich dann anstelle zwei console-inputs (cin&gt;&gt;) in meinem Programm der eine ermittelt den Rechen-Operator der andere den Zahlenwert was ziemlich umständlich ist, umgehen?</p>
</li>
</ol>
<p>Danke im Voraus!</p>
<p>Oh falls ihr meine Source braucht:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;math.h&gt;
#include&lt;windows.h&gt;
using namespace std;

int main(void)
{
    float constantValue = 0, currentValue = 0, x;
    char command;
    const float PI = 4*atan(1);

    do
    {

    cin&gt;&gt;command;
    cin&gt;&gt;constantValue;

        switch(command)
        {
            // main features

            case'+':
            currentValue += constantValue;
            break;

            case'-':
            currentValue -= constantValue;
            break;

            case'*':
            currentValue *= constantValue;
            break;

            case'/':
            currentValue /= constantValue;
            break;

            case'=':
            currentValue = currentValue;
            break;

            case'd':    // destroy
            currentValue = 0;
            constantValue = 0;

            case'n': // new screen
            system(&quot;cls&quot;);
            break;

            break;

            // add-on trigonometric functions ToDo

            case'S': // SINE
            currentValue = ((constantValue*PI)/180);
            currentValue = sin(currentValue);
            break;

            case's': // arcus-sine
            currentValue = asin(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            case'C': // COSINE
            currentValue = ((constantValue*PI)/180);
            currentValue = cos(currentValue);
            break;

            case'c': // arcus-cosine
            currentValue = acos(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            case'T': // TANGENT
            currentValue = ((constantValue*PI)/180);
            currentValue = tan(currentValue);
            break;

            case't': // arcus-tangent
            currentValue = atan(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            // add-on pi constant

            case'p':
            currentValue = PI;
            break;

            // add-on nth power

            case'P':
            currentValue = pow(currentValue, constantValue);
            break;

            // add-on radical

            case'R':
            currentValue = sqrt(currentValue);
            break;

        }

        cout&lt;&lt;currentValue&lt;&lt; endl;

    }
    while(command != 'a'); // abort

}
</code></pre>
<p>PS: Mein aller-erstes C++ Programm... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/231093/c-dynamischer-datentyp</link><generator>RSS for Node</generator><lastBuildDate>Sat, 26 Sep 2026 00:31:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/231093.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Jan 2009 16:37:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [C++] Dynamischer-Datentyp? on Tue, 06 Jan 2009 16:40:28 GMT]]></title><description><![CDATA[<p>Ich bastle mir grad ein Virtuellen Taschenrechner, nun bin ich mit meinem Latein am ende und weiß nicht wie es weiter gehen soll. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Folgendes Problem:</p>
<p>Ich möchte einen Datentyp haben der &quot;automatisch&quot; denn Typ ermittelt wie z.B ob es sich um ein char Datentyp bzw. float Datentyp handelt und dementsprechend konvertiert in dem fall mit cast...</p>
<p>Ich habe mir schon ein FilterSytem ausgedacht:</p>
<p>Pseudo-Filtersystem:</p>
<pre><code class="language-cpp">cin&gt;&gt; whatever;

if(whatever != TYPECHAR) // Wenn whatever ein char-type ist... 
{
	// whatever in ein float-type umwandeln (mit cast)
}
esle
{
	// whatever in ein char-type umwandeln (mit cast)
}
</code></pre>
<p>Fragen:</p>
<ol>
<li>
<p>Wenn ich anstelle des PseudoAusdrucks TYPECHAR, char setze beklagt sich der Compiler. Warum?</p>
</li>
<li>
<p>Existiert überhaupt so ein &quot;dynamischer&quot; Datentyp?<br />
Habe schon vergeblich gegoogelt...</p>
</li>
<li>
<p>Falls nicht wie kann ich dann anstelle zwei console-inputs (cin&gt;&gt;) in meinem Programm der eine ermittelt den Rechen-Operator der andere den Zahlenwert was ziemlich umständlich ist, umgehen?</p>
</li>
</ol>
<p>Danke im Voraus!</p>
<p>Oh falls ihr meine Source braucht:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;math.h&gt;
#include&lt;windows.h&gt;
using namespace std;

int main(void)
{
    float constantValue = 0, currentValue = 0, x;
    char command;
    const float PI = 4*atan(1);

    do
    {

    cin&gt;&gt;command;
    cin&gt;&gt;constantValue;

        switch(command)
        {
            // main features

            case'+':
            currentValue += constantValue;
            break;

            case'-':
            currentValue -= constantValue;
            break;

            case'*':
            currentValue *= constantValue;
            break;

            case'/':
            currentValue /= constantValue;
            break;

            case'=':
            currentValue = currentValue;
            break;

            case'd':    // destroy
            currentValue = 0;
            constantValue = 0;

            case'n': // new screen
            system(&quot;cls&quot;);
            break;

            break;

            // add-on trigonometric functions ToDo

            case'S': // SINE
            currentValue = ((constantValue*PI)/180);
            currentValue = sin(currentValue);
            break;

            case's': // arcus-sine
            currentValue = asin(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            case'C': // COSINE
            currentValue = ((constantValue*PI)/180);
            currentValue = cos(currentValue);
            break;

            case'c': // arcus-cosine
            currentValue = acos(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            case'T': // TANGENT
            currentValue = ((constantValue*PI)/180);
            currentValue = tan(currentValue);
            break;

            case't': // arcus-tangent
            currentValue = atan(constantValue);
            currentValue = ((currentValue*180)/PI);
            break;

            // add-on pi constant

            case'p':
            currentValue = PI;
            break;

            // add-on nth power

            case'P':
            currentValue = pow(currentValue, constantValue);
            break;

            // add-on radical

            case'R':
            currentValue = sqrt(currentValue);
            break;

        }

        cout&lt;&lt;currentValue&lt;&lt; endl;

    }
    while(command != 'a'); // abort

}
</code></pre>
<p>PS: Mein aller-erstes C++ Programm... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1640518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1640518</guid><dc:creator><![CDATA[Individual Code]]></dc:creator><pubDate>Tue, 06 Jan 2009 16:40:28 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Dynamischer-Datentyp? on Tue, 06 Jan 2009 18:09:53 GMT]]></title><description><![CDATA[<p>2+3) Du kannst einen String verwenden:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;string&gt;
#include&lt;cctype&gt;

int main()
{
	std::string calculation(&quot;&quot;);
	getline(std::cin, calculation);
	for( int i=0; i&lt;=calculation.size(); i++ )
	{
		if( isdigit(calculation[i]) )	// == wenn calculation[i] eine zahl ist
		{
			// ...
		}
		else
		{
			// ...
		}
	}
}
</code></pre>
<p>siehe auch:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39488.html" rel="nofollow">Einmal Zahl nach String und zurück</a></p>
<p>EDIT:</p>
<p>Individual Code schrieb:</p>
<blockquote>
<pre><code class="language-cpp">//...
#include&lt;math.h&gt;
#include&lt;windows.h&gt; 
//...
</code></pre>
</blockquote>
<p>- die windows.h brauchst du hier nicht<br />
- math.h in cmath umwandeln</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1640536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1640536</guid><dc:creator><![CDATA[Auma]]></dc:creator><pubDate>Tue, 06 Jan 2009 18:09:53 GMT</pubDate></item></channel></rss>