<?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[invalid conversion]]></title><description><![CDATA[<p>kurz und knapp!<br />
es geht um klassenprogrammierung:</p>
<p>da bringt er ihr beim compilieren den fehler &quot;invalid conversion from `const char*' to `char' &quot;!.<br />
Ich hab aber nun alles durchgeschaut und weiß nicht weiter...:-(</p>
<p>Hab mal den Quelltext angehangen und die betreffende Zeile markiert:<br />
Vielleicht kann mir jemand helfen!</p>
<p>Danke im Vorraus</p>
<p>Quelltext:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class Bestand
      {      
             public:    long Nr;
                        char *Gst;
                        double Wert;
      };

class Kran
      {      
             public:    char *Typ;
                        char *Fa;
                        char Leas;
                        double NKost;

                        Kran (char *typ = &quot;AK-30&quot;,
                              char *fa  = &quot;Allkran&quot;,
                              char leas = &quot;ja&quot;,
                              double nKost = 50.7)

                              { 
                                     Typ = typ;
                                     Fa  = fa;
                                     Leas = leas;
                                     NKost = nKost;
                               }

                        ~Kran(){}
       };

class Verkauf : public Bestand, Kran
      {      
             public:   Verkauf (long nr = 1015,
                                char *gst = &quot;Autokran&quot;,
                                double wert = 132000,
                                char *typ = &quot;AKX-35&quot;,
                                char *fa = &quot;Werner&quot;)

                            :(  {    Nr = nr;
                                     Gst = gst;
                                     Wert = wert;
                                     Typ = typ;
                                     Fa = fa;
                                 }  :( 

                        ~Verkauf(){}
                        double V_Preis();
      };

double Verkauf::V_Preis()
       {
             double VP;
             VP = (Wert + (Wert * NKost)/100)*0,16;
             return VP;
       };

class Sonderpreis : public Verkauf
      {      
             protected:    double Sond;

             public:       double SPr();

                           Sonderpreis (double sond = 12)
                                 {
                                       Sond = sond;
                                 }

                           ~Sonderpreis(){}
      };

double Sonderpreis::SPr()
       {
              double Preis;
              Preis = Verkauf::V_Preis();
              Preis = (1-(Sond/100))*Preis;
              return Preis;
       };
</code></pre>
<p>&lt;edit&gt;Bitte Code-Tags verwenden&lt;/edit&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/136094/invalid-conversion</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 07:22:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136094.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Feb 2006 11:29:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to invalid conversion on Wed, 08 Feb 2006 08:44:49 GMT]]></title><description><![CDATA[<p>kurz und knapp!<br />
es geht um klassenprogrammierung:</p>
<p>da bringt er ihr beim compilieren den fehler &quot;invalid conversion from `const char*' to `char' &quot;!.<br />
Ich hab aber nun alles durchgeschaut und weiß nicht weiter...:-(</p>
<p>Hab mal den Quelltext angehangen und die betreffende Zeile markiert:<br />
Vielleicht kann mir jemand helfen!</p>
<p>Danke im Vorraus</p>
<p>Quelltext:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class Bestand
      {      
             public:    long Nr;
                        char *Gst;
                        double Wert;
      };

class Kran
      {      
             public:    char *Typ;
                        char *Fa;
                        char Leas;
                        double NKost;

                        Kran (char *typ = &quot;AK-30&quot;,
                              char *fa  = &quot;Allkran&quot;,
                              char leas = &quot;ja&quot;,
                              double nKost = 50.7)

                              { 
                                     Typ = typ;
                                     Fa  = fa;
                                     Leas = leas;
                                     NKost = nKost;
                               }

                        ~Kran(){}
       };

class Verkauf : public Bestand, Kran
      {      
             public:   Verkauf (long nr = 1015,
                                char *gst = &quot;Autokran&quot;,
                                double wert = 132000,
                                char *typ = &quot;AKX-35&quot;,
                                char *fa = &quot;Werner&quot;)

                            :(  {    Nr = nr;
                                     Gst = gst;
                                     Wert = wert;
                                     Typ = typ;
                                     Fa = fa;
                                 }  :( 

                        ~Verkauf(){}
                        double V_Preis();
      };

double Verkauf::V_Preis()
       {
             double VP;
             VP = (Wert + (Wert * NKost)/100)*0,16;
             return VP;
       };

class Sonderpreis : public Verkauf
      {      
             protected:    double Sond;

             public:       double SPr();

                           Sonderpreis (double sond = 12)
                                 {
                                       Sond = sond;
                                 }

                           ~Sonderpreis(){}
      };

double Sonderpreis::SPr()
       {
              double Preis;
              Preis = Verkauf::V_Preis();
              Preis = (1-(Sond/100))*Preis;
              return Preis;
       };
</code></pre>
<p>&lt;edit&gt;Bitte Code-Tags verwenden&lt;/edit&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988375</guid><dc:creator><![CDATA[stuff]]></dc:creator><pubDate>Wed, 08 Feb 2006 08:44:49 GMT</pubDate></item><item><title><![CDATA[Reply to invalid conversion on Tue, 07 Feb 2006 11:37:17 GMT]]></title><description><![CDATA[<p>Die nächste Steigerung wäre es gewesen, das ganze schön in cpp-Tags einzuschließen <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="😉"
    /><br />
Dann würde dir vermutlich auch auffallen, daß du im Kran()-Konstruktor den Member 'char Leas' mit einem char* initialisieren willst.</p>
<p>PS: Du solltest vielleicht die Konstruktoren der Basisklasse(n) als Initialisierungsliste anführen.</p>
<p>PPS: Und steig um von char* auf std::string.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988381</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Feb 2006 11:37:17 GMT</pubDate></item><item><title><![CDATA[Reply to invalid conversion on Tue, 07 Feb 2006 11:42:00 GMT]]></title><description><![CDATA[<p>Bitte benutze cpp-Tags. So finde ich nichtmal die von Dir angesprochene Markierung des Fehlers.</p>
<p>Doch, habs gefunden. Der Ausdruck &quot;blabla&quot; im Quelltext (also ein Text in Anführungszeichen) ist ein unveränderlicher Text (Typ const char*). Diesen versuchst Du einem char* zuzuweisen (Typ Zeiger auf veränderlichen Text).</p>
<p>Was hast'n da für'n Compiler, der auf sowas achtet? <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="😉"
    /></p>
<p>EDIT: Hab mich wohl zu sehr auf die markierte Stelle fixiert, war in dem Zusammenhang quatsch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>stuff schrieb:</p>
<blockquote>
<p>Danke im v******</p>
</blockquote>
<p>Schreib's bitte richtig oder garnicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988382</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 07 Feb 2006 11:42:00 GMT</pubDate></item></channel></rss>