<?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[Klassenerstellung- Funktionen konstant setzen]]></title><description><![CDATA[<p>Hi,<br />
ich versuche mich gerade an der Erstellung einer Klasse und habe dazu folgenden Code geschrieben:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

using namespace std;

class Employee
      {
              public:
                     int GetAge()const;
                     void SetAge( int age);
                     int GetSalary() const;
                     void SetSalary(int salary);
                     int GetYearsofservice() const;
                     void SetYearsofservice(int yearsofservice);

              private:
                      int Age;
                      int Salary;
                      int Yearsofservice;
      };

main ()
{
       int age, salary, yearsofservice;
       Employee Sam;
       Employee Sally;
       Sam.SetAge(35);
//       Sam-&gt;SetSalary(35000);
//      Sam-&gt;SetYearsofservice(10);
       Sally.SetAge(40);
//       Sally.SetSalary(25000);
//       Sally.SetYearsofservice(18);

       cout &lt;&lt; &quot;Sam und Sally arbeiten beide in der Firma X/n&quot;;
       cout &lt;&lt; &quot;Sam´s Daten:\n Alter:&quot; &lt;&lt; Sam.GetAge() &lt;&lt;&quot;\n&quot;;
}

      int Employee::GetAge()
          {
                            return Age;
          }

      void Employee::SetAge(int age)
           {
                             Age = age;
           }
</code></pre>
<p>wenn ich nun in der Klassendekleration GetAge nicht mehr const setze funktioniert es. wiekann ich ereichen, dass GetAge konstant ist und das programm trotzdem fuktioniert?<br />
hab auch schon in schaum´s nachgeschaut, aber irgentwie klappt es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/170878/klassenerstellung-funktionen-konstant-setzen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 05:29:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170878.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Jan 2007 15:08:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klassenerstellung- Funktionen konstant setzen on Sat, 20 Jan 2007 15:08:11 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich versuche mich gerade an der Erstellung einer Klasse und habe dazu folgenden Code geschrieben:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

using namespace std;

class Employee
      {
              public:
                     int GetAge()const;
                     void SetAge( int age);
                     int GetSalary() const;
                     void SetSalary(int salary);
                     int GetYearsofservice() const;
                     void SetYearsofservice(int yearsofservice);

              private:
                      int Age;
                      int Salary;
                      int Yearsofservice;
      };

main ()
{
       int age, salary, yearsofservice;
       Employee Sam;
       Employee Sally;
       Sam.SetAge(35);
//       Sam-&gt;SetSalary(35000);
//      Sam-&gt;SetYearsofservice(10);
       Sally.SetAge(40);
//       Sally.SetSalary(25000);
//       Sally.SetYearsofservice(18);

       cout &lt;&lt; &quot;Sam und Sally arbeiten beide in der Firma X/n&quot;;
       cout &lt;&lt; &quot;Sam´s Daten:\n Alter:&quot; &lt;&lt; Sam.GetAge() &lt;&lt;&quot;\n&quot;;
}

      int Employee::GetAge()
          {
                            return Age;
          }

      void Employee::SetAge(int age)
           {
                             Age = age;
           }
</code></pre>
<p>wenn ich nun in der Klassendekleration GetAge nicht mehr const setze funktioniert es. wiekann ich ereichen, dass GetAge konstant ist und das programm trotzdem fuktioniert?<br />
hab auch schon in schaum´s nachgeschaut, aber irgentwie klappt es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1213214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1213214</guid><dc:creator><![CDATA[Dalamar]]></dc:creator><pubDate>Sat, 20 Jan 2007 15:08:11 GMT</pubDate></item><item><title><![CDATA[Reply to Klassenerstellung- Funktionen konstant setzen on Sat, 20 Jan 2007 15:19:07 GMT]]></title><description><![CDATA[<p>Zeile 37:</p>
<p>int Employee::GetAge() const</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1213220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1213220</guid><dc:creator><![CDATA[Helfender]]></dc:creator><pubDate>Sat, 20 Jan 2007 15:19:07 GMT</pubDate></item><item><title><![CDATA[Reply to Klassenerstellung- Funktionen konstant setzen on Sat, 20 Jan 2007 15:41:26 GMT]]></title><description><![CDATA[<p>ok, das war einfach,<br />
hatte ich wohl übersehen. vielen dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1213235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1213235</guid><dc:creator><![CDATA[Dalamar]]></dc:creator><pubDate>Sat, 20 Jan 2007 15:41:26 GMT</pubDate></item><item><title><![CDATA[Reply to Klassenerstellung- Funktionen konstant setzen on Sat, 20 Jan 2007 15:46:41 GMT]]></title><description><![CDATA[<p>Einfach die Fehlermeldung etwas genauer lesen <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1213239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1213239</guid><dc:creator><![CDATA[Helfender]]></dc:creator><pubDate>Sat, 20 Jan 2007 15:46:41 GMT</pubDate></item></channel></rss>